Browse thread
Constructors are not functions
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2009-10-10 (06:25) |
From: | Goswin von Brederlow <goswin-v-b@w...> |
Subject: | Re: [Caml-list] Constructors are not functions |
"David Allsopp" <dra-news@metastack.com> writes: > Goswin von Brederlow wrote: > <snip> >> Then what about >> >> type t1 = Bar of int * int >> type t2 = Foo of (int * int) >> >> If you treat constructors as functions taking one argument then > > But why (so arbitrarily) do this? Because that was what the mentioned material said. >> t1: int * int -> t1 >> t2: int * int -> t2 > > If you look at each type definition and choose those most appropriate, then: > > t1: int -> int -> t1 > t2: int * int -> t2 > > I don't see your point (but this is pre-coffee!)? The fact that you write > [Bar(1, 2)] for a two-constructor variant tag and [bar 1 2] for a "2 > argument" function is just an (occasionally irritating) oddity of the OCaml > syntax - it wouldn't have to affect any derived constructor functions here. Actualy you do see my point. My point was that the appropriate type should be used. > However, the impracticality of importing the types from other interfaces > (see Richard Jones post in this thread) has already revealed that this > couldn't be done transparently in the way I'd initially thought so it's > become a bit of a thought experiment anyway :o) > > > David MfG Goswin