From: "Loup Vaillant" <loup.vaillant@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Polymorphic recursion
Date: Tue, 3 Apr 2007 18:59:43 +0200 [thread overview]
Message-ID: <6f9f8f4a0704030959l8ebb155g8532e3ee6d31c66d@mail.gmail.com> (raw)
I was reading Okasaki's book, "Purely functionnal data structures",
and discovered that ML (and Ocaml) doesn't support non uniforms
function definitions.
So, even if:
(**)
type 'a seq = Unit | Seq of ('a * ('a * 'a)seq);;
(**)
is correct,
(**)
let rec size = fun
| Unit -> 0
| Seq(_, b) -> 1 + 2 * size b;;
(**)
is not. Here is the error:
#
| Seq(_, b) -> 1 + 2 * size b;;
This expression (the last 'b') has type seq ('a * 'a) but is here used
with type seq 'a
#
Why?
Can't we design a type system which allow this "size" function?
Can't we implement non uniform recursive function (efficiently, or at all)?.
I suppose the problem is somewhat difficult, but I can't see where.
Regards,
Loup Vaillant
next reply other threads:[~2007-04-03 16:59 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-03 16:59 Loup Vaillant [this message]
2007-04-03 17:20 ` [Caml-list] " Jeremy Yallop
2007-04-04 5:27 ` Alain Frisch
2007-04-04 12:54 ` Loup Vaillant
2007-04-03 17:35 ` Till Varoquaux
2007-04-03 20:00 ` brogoff
2007-04-04 1:27 ` skaller
2007-04-04 1:40 ` skaller
2007-04-04 13:49 ` Roland Zumkeller
2007-04-04 15:13 ` Alain Frisch
2007-04-04 15:20 ` Alain Frisch
2007-04-04 16:45 ` Roland Zumkeller
2007-04-04 19:58 ` Alain Frisch
2007-04-04 20:13 ` brogoff
2007-04-05 9:33 ` Roland Zumkeller
2007-04-05 9:54 ` Alain Frisch
2007-04-05 10:07 ` Daniel de Rauglaudre
2007-04-05 9:46 ` Francois Maurel
2007-04-04 15:50 ` Stefan Monnier
2007-04-04 23:36 ` [Caml-list] " Brian Hurt
2007-04-05 8:17 ` Loup Vaillant
-- strict thread matches above, loose matches on Subject: below --
2008-05-12 21:55 polymorphic recursion Jacques Le Normand
1999-08-22 20:35 Polymorphic recursion Hongwei Xi
1999-08-23 12:19 ` Pierre Weis
1998-09-21 16:30 polymorphic recursion Peter J Thiemann
1998-09-22 2:33 ` Jacques GARRIGUE
1998-09-22 9:22 ` Pierre Weis
1998-09-22 10:00 ` Simon Helsen
1998-09-22 15:06 ` Pierre Weis
1998-09-22 15:28 ` Simon Helsen
1998-09-22 16:33 ` Pierre Weis
1998-09-22 15:50 ` Pierre CREGUT - FT.BD/CNET/DTL/MSV
1998-09-22 17:14 ` Xavier Leroy
1998-09-28 9:51 ` Pierre Weis
1998-09-28 11:45 ` Peter Thiemann
1998-09-28 13:00 ` Pierre Weis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6f9f8f4a0704030959l8ebb155g8532e3ee6d31c66d@mail.gmail.com \
--to=loup.vaillant@gmail.com \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox