* Interpretation of an error message "type ('a, 'b) t should be ('a, 'c) t" in a signature?
@ 2009-04-20 20:45 Jean Balthazar
2009-04-21 2:45 ` [Caml-list] " Jacques Garrigue
0 siblings, 1 reply; 2+ messages in thread
From: Jean Balthazar @ 2009-04-20 20:45 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 814 bytes --]
Dear caml-list,
I try to define the signature of three interdependant classes that should
then be derived and completed for various implementation. The code below
causes the strange error messsage:
File "tmp.ml", line 4, characters 7-92:
In the definition of job, type ('a, 'b) batch should be ('a, 'c)
batch
Can you explain what is wrong with this signature?
I was unable to find an answer to a similar problem in the archives.
Thank you very much.
Jean
----------------------------------------------------------------------------
module type JOB =
sig
type ('a, 'b) batch = private < build : 'a job -> ('a priority * 'a) list
-> 'b job; .. >
and 'b priority = private < next : 'b priority; .. >
and 'a job = private < create_batch : 'c.('a -> 'c) -> ('a, 'c) batch;
.. >
end
[-- Attachment #2: Type: text/html, Size: 1045 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] Interpretation of an error message "type ('a, 'b) t should be ('a, 'c) t" in a signature?
2009-04-20 20:45 Interpretation of an error message "type ('a, 'b) t should be ('a, 'c) t" in a signature? Jean Balthazar
@ 2009-04-21 2:45 ` Jacques Garrigue
0 siblings, 0 replies; 2+ messages in thread
From: Jacques Garrigue @ 2009-04-21 2:45 UTC (permalink / raw)
To: jean.balthazar.fr; +Cc: caml-list
This is exactly the same problem as your previous post.
You are trying to define a non-regular type.
I.e., if you expand the definition of job, you get:
type ('a,'b) batch = private
< build : < create_batch : 'c.('a -> 'c) -> ('a,'c) batch; .. > ->
('a priority * 'a) list ->
< create_batch : 'c.('b -> 'c) -> ('b,'c) batch; .. > ;
.. >
(not a correct definition because job itself is a private row type,
but this is just to show explicitly the occurences of batch)
All occurences of batch inside its own definition should have the same
parameters ('a,'b), but here both have different parameters.
I admit that the error message is a bit confusing because all
parameters are variables, and their names are not preserved by the
type-checker. If the name were preserved, this would be
type ('a, 'c) batch should be ('a, 'b)
Jacques Garrigue
From: Jean Balthazar <jean.balthazar.fr@gmail.com>
> I try to define the signature of three interdependant classes that should
> then be derived and completed for various implementation. The code below
> causes the strange error messsage:
>
> File "tmp.ml", line 4, characters 7-92:
> In the definition of job, type ('a, 'b) batch should be ('a, 'c)
> batch
>
> Can you explain what is wrong with this signature?
> I was unable to find an answer to a similar problem in the archives.
>
> Thank you very much.
> Jean
>
> ----------------------------------------------------------------------------
>
> module type JOB =
> sig
>
> type ('a, 'b) batch = private < build : 'a job -> ('a priority * 'a) list
> -> 'b job; .. >
> and 'b priority = private < next : 'b priority; .. >
> and 'a job = private < create_batch : 'c.('a -> 'c) -> ('a, 'c) batch;
> .. >
>
> end
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-04-21 2:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-20 20:45 Interpretation of an error message "type ('a, 'b) t should be ('a, 'c) t" in a signature? Jean Balthazar
2009-04-21 2:45 ` [Caml-list] " Jacques Garrigue
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox