Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] variant with tuple arg in pattern match?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: reig@d...
Subject: Re: [Caml-list] variant with tuple arg in pattern match?
> Michel Mauny wrote:
> 
> > Sure. With CamlP4's revised syntax, you would write this as
> > 
> >    type t 'a =3D
> >      I of int
> >    | B of bool
> >    | N of (t 'a) and (t 'a)      (* parens probably unnecessary *)
> >    | Uncurried of int * int
> > 
> Like in haskell, if it *looks* curried, it *is* curried.
> 
> data T a = Curried (T a) (T a) 
>          | Function (T a -> T a)
> 

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

After all, we already use juxtaposition for curried function
definitions:

let f x y = ...
fun x y -> ...

Fermin Reig
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr