Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] module type and record
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] module type and record
> hello,
> I need to declare a record type in a field like :
> 
> module A : ( MY_TYPE with type t = { label1 : int ; label2 : string } ) =
> struct
> ....
> end
> 
> but the compiler seems to refuse this declaration.

Currently, only type abbreviations can be added with the "with type"
construct:  MODTYPE with type t = some_type_expression.

This restriction is somewhat artificial and I'm considering lifting it.

> Could you give me a solution for this problem ?

Currently, you need to expand "MY_TYPE with..." by hand into

        sig
          type t = { label1 : int ; label2 : string }
          (* other elements of signature MY_TYPE
        end

An alternative is to declare the record type separately:

        type my_rec = { label1 : int ; label2 : string }

        module A : (MY_TYPE with type t = my_rec) = ...

- Xavier Leroy

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners