Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Constructors are not functions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-10-06 (14:04)
From: David Allsopp <dra-news@m...>
Subject: RE: [Caml-list] Constructors are not functions
Jon Harrop wrote:
> David Allsopp wrote:
> > I think it would be possible to simulate the SML behaviour in OCaml
> > using camlp4 (if you assume that for [type foo = Bar of int] that future
> > unbound references to [bar] are interpreted as [fun x -> bar x] instead of an
> > error)
> Only if you turned multi-argument type constructors into single-
> argument ones
> taking a tuple, i.e. type definitions like:
>   type t = Bar of int * int
> must become:
>   type t = Bar of (int * int)

That's not the case at all - there'd be no reason not to interpret [bar] as [fun x y -> Bar(x, y)] for [Bar of int * int]. What would be hairy in camlp4 would be having to read .cmi files to deal with types defined outside your source file, but that's still not impossible...