Version française
Home     About     Download     Resources     Contact us    
Browse thread
How to expose sum type constructors to an interface
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Julien Moutinho <julien.moutinho@g...>
Subject: Re: [Caml-list] How to expose sum type constructors to an interface
On Thu, Oct 18, 2007 at 02:16:50AM +0200, Felix Dorner wrote:
> In my implementation file module.ml I define: type aType = A | B
> How I now need to expose this Type and its constructors to the interface  
> module.mli, because some of the functions declared in the interface take a 
> parameter of type "aType". How can I do this?

The toplevel or the flag
  -i  Print inferred interface
may help you :)

% cat file.ml
type a_type = A | B

let f =
    function
    | A -> B
    | _ -> A
% ocamlc -i file.ml
type a_type = A | B
val f : a_type -> a_type

A few pointers that may help too:
http://caml.inria.fr/pub/docs/oreilly-book/html/book-ora130.html#toc180
http://caml.inria.fr/pub/docs/manual-ocaml/manual018.html#@manual.kwd135