English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    
Browse thread
[Caml-list] How to read three integers from a text-file... ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alain Frisch <frisch@c...>
Subject: Re: [Caml-list] Extensible tuple types
On Thu, 2 May 2002, Francois Pottier wrote:

> On Tue, Apr 30, 2002 at 04:42:01PM +0200, Jocelyn Sérot wrote:
> >
> > Sorry to jump in the middle of this discussion, but your last remark on
> > "extensible
> > n-tuples" drew my attention (i use to need this kind of thing in a
> > completely different
> > context). Can you provide references on these extensions of ML type
> > systems ?
>
> Tuples can be viewed as records whose field labels are integers, rather than
> names. (In particular, this means that tuple fields do not commute, contrary
> to record fields.) Records can be typed in a flexible way using rows; see
> Didier Rémy's papers, for instance ``Type Inference for Records in a Natural
> Extension of ML''. In the case of tuples, it's possible to use a variant of
> rows -- I'll call them ``sequences'' -- to describe an infinite sequence of
> types.

I don't understand what this encoding of extensible tuples allows,
compared to the simple minded solution [the type of an n-typle is
(t1,(t2,...(tn,unit)...)) ]


> The operation which accepts any tuple, of length at least k, and returns
> its k-th component, has type
>
>   forall 'a_1, ..., 'a_k, 's.
>     ('a_1; ...; 'a_{k-1}; Present('a_k); 's) -> 'a_k

fun (x1,(x2,...(xk,_)...)) -> xk

> The operation which accepts any tuple and adds a new component in front
> of it has type
>
>   forall 'a, 's.
>     'a -> ('s) -> (Present('a); 's)


fun x c -> (x,c)


-- Alain

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners