#
Objective Caml version 3.11.1
Camlp4 Parsing version 3.11.1
# type bar = 'a ;
Error: Unbound type parameter 'a
http://caml.inria.fr/pub/docs/manual-camlp4/manual007.html
Thanks,
--
Serge Leblanc
gpg --keyserver hkp://keyserver.ubuntu.com:11371 --recv-keys 0x33243C1B
Fingerprint = 066C 005F 5595 D85C 7673 D969 1DD4 90C4 3324 3C1B
The documentation is too old, abstract types now have the same syntax in
revised than in the original OCaml syntax.
--
Nicolas Pouillard
http://nicolaspouillard.fr
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
Any chance that it will be updated any time soon?
--
Stefano Zacchiroli -o- PhD in Computer Science \ PostDoc @ Univ. Paris 7
zack@{upsilon.cc,pps.jussieu.fr,debian.org} -<>- http://upsilon.cc/zack/
Dietro un grande uomo c'� ..| . |. Et ne m'en veux pas si je te tutoie
sempre uno zaino ...........| ..: |.... Je dis tu � tous ceux que j'aime
> Excerpts from Serge Leblanc's message of Thu Dec 10 12:56:44 +0100 2009:
> > Hi, the documentation for the revised syntax explain that abstract types
> > are expressed by :
>
> The documentation is too old, abstract types now have the same syntax in
> revised than in the original OCaml syntax.
>
In the following types definitions,
type trie 'a = [ Trie of arcs 'a ]
and arcs 'a = list ('a * trie 'a);
type zipper 'a = [ Top | Zip of (arcs 'a * 'a * arcs 'a * zipper 'a) ]
and edit_state 'a = (zipper 'a * trie 'a);
why is it not possible to describe them thus ?
type letter = 'a;
type trie = [ Trie of arcs ]
and arcs = list (letter * trie);
type zipper = [ Top | Zip of (arcs * letter * arcs * zipper) ]
and edit_state = (zipper * trie);
Thanks for your help.
Note first that revised syntax is just syntax, it does not change the
semantics. So, translating your question on a simpler example in
standard syntax, how does
type 'a list = Nil | Cons of 'a * 'a list
relate to
type elt
type list = Nil | Cons of elt * list
The answer is that they describe the same data, but in an incompatible
way. The first approach uses ML polymorphism, so that you can build a
list of any given type, letting the type checker choose the element
type.
The second is a signature, and should be used in combination with
functors, the type being chosen explicitly. For instance, you can
write a map function in the following way:
module type List = sig
type elt
type list = Nil | Cons of elt * list
end
module F(T:List) = struct
open T
let rec map f = function
Nil -> Nil
| Cons (h,t) -> Cons (f h, map f t)
end
module IntList = struct
type elt = int
type list = Nil | Cons of elt * list
end
module IntM = F(IntList);;
IntM.map succ (IntList.Cons (1, IntList.Nil));;
Again, these two definitions of list, while representing the same data,
are incompatible.
Hope this helps.
Jacques Garrigue