**Next message:**Jacques GARRIGUE: "Re: polymorphic recursion"**Previous message:**Ken Wakita: "ocamlman 2.00"**In reply to:**Pierre Weis: "Re: Bug converting numbers?"**Next in thread:**Jacques GARRIGUE: "Re: polymorphic recursion"**Maybe reply:**Jacques GARRIGUE: "Re: polymorphic recursion"**Maybe reply:**Xavier Leroy: "Re: polymorphic recursion"**Maybe reply:**Pierre Weis: "Re: polymorphic recursion"**Maybe reply:**Peter Thiemann: "Re: polymorphic recursion"**Messages sorted by:**[ date ] [ thread ] [ subject ] [ author ]

Date: Mon, 21 Sep 1998 17:30:34 +0100

From: Peter J Thiemann <pjt@cs.nott.ac.uk>

To: caml-list@inria.fr

Subject: polymorphic recursion

In some languages (most notably Haskell and Miranda) it is possible

to define a function that enjoys polymorphic recursion, i.e., the

types of its recursive calls may be instances of the type scheme at

which the function is defined.

For example:

let rec f x =

let q = f true in

let r = f 0 in

x;;

is rejected by OCaml, but it is accepted by Haskell by saying

f :: a -> a

f x = let q = f True in

let r = f 0 in

x

Question:

Can you do the same in OCaml? I am aware of the tricks mentioned in

the FAQ, but I would like to know if there is a cleaner way to do it,

for example by providing a type signature.

-Peter

**Next message:**Jacques GARRIGUE: "Re: polymorphic recursion"**Previous message:**Ken Wakita: "ocamlman 2.00"**In reply to:**Pierre Weis: "Re: Bug converting numbers?"**Next in thread:**Jacques GARRIGUE: "Re: polymorphic recursion"**Maybe reply:**Jacques GARRIGUE: "Re: polymorphic recursion"**Maybe reply:**Xavier Leroy: "Re: polymorphic recursion"**Maybe reply:**Pierre Weis: "Re: polymorphic recursion"**Maybe reply:**Peter Thiemann: "Re: polymorphic recursion"**Messages sorted by:**[ date ] [ thread ] [ subject ] [ author ]

*
This archive was generated by hypermail 2b29
: Sun Jan 02 2000 - 11:58:16 MET
*