Version française
Home     About     Download     Resources     Contact us    
Browse thread
type aliases and recursive modules
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Philippe Wang <lists@p...>
Subject: Re: [Caml-list] type aliases and recursive modules
Josh Berdine wrote:
>
> Thanks Philippe and Christopher, yes, mea culpa, I forgot, e.g., a 
> call to choose.  But my confusion remains:
>
>  
>
> #
>
> 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 (C.choose x))
>
> end
>
> ;;
>
>                                       Characters 350-370:
>
>     let get_its_elements x = C.elements (A.get (C.choose x))
>
>                                         ^^^^^^^^^^^^^^^^^^^^
>
> This expression has type ASet.t but is here used with type
>
>   C.t = Set.Make(A).t
>
> #
>
>  
>
>  
>
> Am I still doing something stupid?
>
>  
>
> Cheers,  Josh
>
Hi,

Your A.get function takes something of the form "It of something", which 
is of type A.t = It of ASet.t.
There is no such a constructor (It) in,
let get_its_elements x = C.elements (A.get (C.choose x))
So it can't go right when you call A.get...
;-)

Cheers,
--
  Philippe Wang
  mail@philippewang.info