Browse thread
Unexpected restriction in "let rec" expressions
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Loup Vaillant <loup.vaillant@g...> |
| Subject: | Unexpected restriction in "let rec" expressions |
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