Version française
Home     About     Download     Resources     Contact us    
Browse thread
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alessandro Baretta <alex@b...>
Subject: [Caml-list] Re: how to start


climb wrote:
> Dear caml-list
>  
>  i am a new commer of Caml language.

Welcome on board!

> and start with online mannul
>  i am confused at this sentence in Chapter 1
> # type idref={ mutable id : 'a. 'a -> 'a};;
> what does "." mean?

'a. 'a -> 'a

This is read as: "For every type 'a, a function from 'a to
'a". In this context 'a is a type variable. The type
variable preceding the "." are "universally quantified":
this is where the "For every type ..." comes into the game.

This basically states that the type of id is polymorphic: 'a
-> 'a  is a type schema as opposed to a specific type. Many
different types fit this schema:
int -> int
string -> string
(int -> int) -> (int -> int), and so on.

The type schema 'a. 'a -> 'a is entirely equivalent to the
axiom schema of propositional calculus A => A: "If A then
A." A stands for *any* proposition, not for any one specific
proposition.


> why i can not write 
> # type intidref= { mutable id : int. int->int};;

This does not make sense because "int" is a type value and
not a type variable.


Alex

-------------------
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