From: Philippe Wang <lists@philippewang.info>
To: Josh Berdine <berdine@dcs.qmul.ac.uk>, ocaml ml <caml-list@inria.fr>
Subject: Re: [Caml-list] type aliases and recursive modules
Date: Tue, 15 May 2007 18:29:17 +0200 [thread overview]
Message-ID: <4649DFDD.6040409@philippewang.info> (raw)
In-Reply-To: <02bd01c79707$7b9d4c60$72d7e520$@qmul.ac.uk>
Josh Berdine wrote:
>
> Hi,
>
> There’s something I’m not understanding about recursive modules.
> Consider the following distilled example:
>
> #
>
> module rec A : sig
>
> type t = It of ASet.t
>
> val compare : t -> t -> int
>
> val get : t -> ASet.t
>
> end = struct
>
> type t = It of ASet.t
>
> let compare = compare
>
> let get = function It(x) -> x
>
> end
>
> and ASet : sig
>
> type t
>
> val get_its_elements : t -> A.t list
>
> end = struct
>
> module C = Set.Make(A)
>
> type t = C.t
>
> let get_its_elements x = C.elements (A.get x)
>
> end
>
> ;;
>
> Characters 350-359:
>
> let get_its_elements x = C.elements (A.get x)
>
> ^^^^^^^^^
>
> This expression has type ASet.t but is here used with type
>
> C.t = Set.Make(A).t
>
> #
>
> Why doesn’t the typechecker know that ASet.t and C.t are the same
> type? Anyone know a workaround?
>
> This is with the 3.10.0 beta version, but seems to be the same back to
> 3.07.
>
> Cheers, Josh
>
Hi,
There is an incoherency in your definition of ASet.get_its_elements.
In the signature of ASet, get_its_elements take an argument of type
ASet.t, but then in its definition, it takes an argument of type A.t (as
A.get takes an argument of type A.t, and you give ASet.get_its_elements'
argument to A.get)
--
Philippe Wang
mail@philippewang.info
next prev parent reply other threads:[~2007-05-15 16:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-15 15:40 Josh Berdine
2007-05-15 16:29 ` Philippe Wang [this message]
2007-05-15 16:56 ` [Caml-list] " Josh Berdine
2007-05-15 17:11 ` Philippe Wang
2007-05-15 17:40 ` Andreas Rossberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4649DFDD.6040409@philippewang.info \
--to=lists@philippewang.info \
--cc=berdine@dcs.qmul.ac.uk \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox