From: Mathias Kende <mathias@kende.fr>
To: caml-list@yquem.inria.fr
Subject: forbidden construct as right hand side of "let rec"
Date: Fri, 23 Oct 2009 00:22:01 +0200 [thread overview]
Message-ID: <1256250121.4178.37.camel@MATHIAS-ENS> (raw)
Hello list,
I need to write something like this :
let f f i = if i = 0 then 1 else i * f (i - 1)
let rec g = f g
Of course the compiler won't let me write it (even if the OCaml type
system is happy):
"This kind of expression is not allowed as right-hand side of `let rec'"
But as the function parameter of function f is used only for a recursive
call I believe that the function I try the define is at least "morally"
correct.
Is there a way to express this sort of construction in OCaml ? My aim is
to be able to have some things equivalent to:
let rec g = f g
and
let rec h = t (f h)
where t is some transformation over the function (conserving its type),
and still writing the code for f only once.
Regards,
Mathias
next reply other threads:[~2009-10-22 22:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-22 22:22 Mathias Kende [this message]
2009-10-22 22:34 ` [Caml-list] " Stéphane Glondu
2009-10-22 23:10 ` Lukasz Stafiniak
2009-10-23 15:35 ` Damien Guichard
2009-10-23 16:14 ` Marc de Falco
2009-10-23 17:51 ` blue storm
2009-10-25 14:11 ` Mathias Kende
2009-10-25 15:03 ` Stéphane Glondu
2009-10-28 16:52 ` Xavier Leroy
2009-10-28 22:44 ` Lukasz Stafiniak
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=1256250121.4178.37.camel@MATHIAS-ENS \
--to=mathias@kende.fr \
--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