caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Unexpected restriction in "let rec" expressions
@ 2008-02-26 12:24 Loup Vaillant
  2008-02-26 14:04 ` [Caml-list] " Jean-Christophe Filliâtre
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Loup Vaillant @ 2008-02-26 12:24 UTC (permalink / raw)
  To: Caml List

hello,

I was trying to translate this simple Haskell definition in Ocaml:

loop :: ((a,c) -> (b,c)) -> a -> b
loop f a = b
  where (b,c) = f (a,c)

However, the direct translation doesn't work:

# let loop f a =
  let rec (b, c) = f (a, c) in
    b;;
    Characters 25-31:
    let rec (b, c) = f (a, c) in
            ^^^^^^
Only variables are allowed as left-hand side of `let rec'

So I try to bypass this restriction:

# let loop f a =
  let rec couple = f (a, snd couple) in
    fst couple;;
    Characters 34-51:
    let rec couple = f (a, snd couple) in
                     ^^^^^^^^^^^^^^^^^
This kind of expression is not allowed as right-hand side of `let rec'


Any ideas about what is this restriction, an what is it for?

Thanks,
Loup


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2008-02-27 23:46 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-26 12:24 Unexpected restriction in "let rec" expressions Loup Vaillant
2008-02-26 14:04 ` [Caml-list] " Jean-Christophe Filliâtre
2008-02-26 14:18 ` Damien Doligez
2008-02-26 14:34   ` Loup Vaillant
2008-02-26 14:51     ` Gabriel Kerneis
2008-02-26 14:56     ` blue storm
2008-02-26 17:48     ` Nicolas Pouillard
2008-02-26 14:57 ` Dirk Thierbach
2008-02-27  8:53 ` Andrej Bauer
2008-02-27  9:43   ` Loup Vaillant
2008-02-27 12:02     ` Dirk Thierbach
2008-02-27 14:04       ` Loup Vaillant
2008-02-27 16:41         ` Dirk Thierbach
2008-02-27 23:32           ` Loup Vaillant
2008-02-27 19:03 ` Pal-Kristian Engstad
2008-02-27 23:46   ` Loup Vaillant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).