Browse thread
Re: [Caml-list] variant with tuple arg in pattern match?
-
reig@d...
- Michel Mauny
- Marcin 'Qrczak' Kowalczyk
[
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: | -- (:) |
| From: | Michel Mauny <Michel.Mauny@i...> |
| Subject: | Re: [Caml-list] variant with tuple arg in pattern match? |
reig@dcs.gla.ac.uk wrote/écrivait (Apr 10 2001, 01:10PM +0100):
> In fact, the syntax for the type definition could be like in haskell:
> use juxtaposition.
>
> type 'a t = Curried : ('a t) ('a t)
> | Function : 'a t -> 'a t
>
In this case, there is an ambiguity between curryfication and type
constructors application.
In
type t = C : int bool
is C of type int -> bool -> t, or is bool a unary type constructor,
with int as argument. Compare with
type t = C : int list
for instance. Parsing would need typing information, here.
Haskell avoids this in using the same notation (juxtaposition) all the
way long. That is, the examples above would be written as
type t = C int bool
type t = C (int list)
and made unambiguous using parens. Using a `:' right after the data
constructor is (to me) less clear than the Haskell notation. Maybe
because of type constraints and module interfaces.
--
Michel
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr