caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Bug or useless error message
@ 2015-08-27 13:52 Christoph Höger
  2015-08-27 14:10 ` Jacques Garrigue
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Höger @ 2015-08-27 13:52 UTC (permalink / raw)
  To: Ocaml Mailing List

Dear all,

right now I am unable to produce a working example of that problem, so
please bear with me.

Basically, I just patched ppx_deriving_yojson to generate polymorphic
functions for recursive types, i.e.

type 'a foo = ...
 and bar = int foo [@@deriving yojson]

becomes

let rec foo_of_yojson : 'a. (json -> [`Ok of 'a, `Error of string]) ->
json -> [`Ok of 'a, `Error of string] = ...
and bar_of_yojson = ...

this does, indeed, work in the test cases.

If I apply this method to my (large) real world module, I get a strange
error:

Error: Signature mismatch:
       ...
       Values do not match:
         val typedef_struct_of_yojson :
           (Yojson.Safe.json -> [ `Error of string | `Ok of 'a ]) ->
           Yojson.Safe.json ->
           [ `Error of string | `Ok of 'a typedef_struct ]
       is not included in
         val typedef_struct_of_yojson :
           (Yojson.Safe.json -> [ `Error of string | `Ok of 'a ]) ->
           Yojson.Safe.json ->
           [ `Error of string | `Ok of 'a typedef_struct ]

Syntactically, the types are the same, but obviously they are not equal
in their internal representation.

I can workaround this problem by hiding this particular function from
the interface (yes, it only occurs in one function out of ~300).
However, this message bugs me: Is something like this expected when
using explicit generalization?

regards,

Christoph

-- 
Christoph Höger

Technische Universität Berlin
Fakultät IV - Elektrotechnik und Informatik
Übersetzerbau und Programmiersprachen

Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin

Tel.: +49 (30) 314-24890
E-Mail: christoph.hoeger@tu-berlin.de

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Bug or useless error message
  2015-08-27 13:52 [Caml-list] Bug or useless error message Christoph Höger
@ 2015-08-27 14:10 ` Jacques Garrigue
  0 siblings, 0 replies; 2+ messages in thread
From: Jacques Garrigue @ 2015-08-27 14:10 UTC (permalink / raw)
  To: Christoph Höger; +Cc: OCaml Mailing List

You should submit a bug report, with all the source files required.
Impossible to tell you anything without more information.

Jacques Garrigue

On 2015/08/27 22:52, Christoph Höger wrote:
> 
> Dear all,
> 
> right now I am unable to produce a working example of that problem, so
> please bear with me.
> 
> Basically, I just patched ppx_deriving_yojson to generate polymorphic
> functions for recursive types, i.e.
> 
> type 'a foo = ...
> and bar = int foo [@@deriving yojson]
> 
> becomes
> 
> let rec foo_of_yojson : 'a. (json -> [`Ok of 'a, `Error of string]) ->
> json -> [`Ok of 'a, `Error of string] = ...
> and bar_of_yojson = ...
> 
> this does, indeed, work in the test cases.
> 
> If I apply this method to my (large) real world module, I get a strange
> error:
> 
> Error: Signature mismatch:
>       ...
>       Values do not match:
>         val typedef_struct_of_yojson :
>           (Yojson.Safe.json -> [ `Error of string | `Ok of 'a ]) ->
>           Yojson.Safe.json ->
>           [ `Error of string | `Ok of 'a typedef_struct ]
>       is not included in
>         val typedef_struct_of_yojson :
>           (Yojson.Safe.json -> [ `Error of string | `Ok of 'a ]) ->
>           Yojson.Safe.json ->
>           [ `Error of string | `Ok of 'a typedef_struct ]
> 
> Syntactically, the types are the same, but obviously they are not equal
> in their internal representation.
> 
> I can workaround this problem by hiding this particular function from
> the interface (yes, it only occurs in one function out of ~300).
> However, this message bugs me: Is something like this expected when
> using explicit generalization?
> 
> regards,
> 
> Christoph




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-27 14:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-27 13:52 [Caml-list] Bug or useless error message Christoph Höger
2015-08-27 14:10 ` Jacques Garrigue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).