From: Ville-Pertti Keinonen <will@exomi.com>
To: Peter Scott <sketerpot@chase3000.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Recursive apply function
Date: Thu, 20 Nov 2003 12:45:54 +0200 [thread overview]
Message-ID: <20031120104554.GA1387@exomi.com> (raw)
In-Reply-To: <5.2.0.9.0.20031119204912.00a9fb28@127.0.0.1>
On Wed, Nov 19, 2003 at 08:54:08PM -0700, Peter Scott wrote:
> first element of the list. Unfortunately, I get this message when run:
> "This expression has type 'a but is here used with type 'b -> 'a",
> referring to the "(f arg)" part.
You can get your "apply" function to typecheck using the -rectypes option,
but it still doesn't do what you want; it only accepts functions that
return functions of the same (recursive) type.
Static typing prevents things like Lisp apply from being implemented
even for the limited case where arguments have the same type. The type
of a partially applied function is almost never identical to the fully
applied function (except for the case of recursively typed functions that
return functions, such as your "apply").
Note that the -rectypes option is probably not something you want to use
unless you know that you need it. An example is if you want to have a
state machine with functions representing states without resorting to
side-effects (f : event -> action * 'a as 'a).
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
prev parent reply other threads:[~2003-11-20 10:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-20 3:54 Peter Scott
2003-11-20 4:41 ` Aleksey Nogin
2003-11-20 7:31 ` Brian Hurt
2003-11-20 10:45 ` Ville-Pertti Keinonen [this message]
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=20031120104554.GA1387@exomi.com \
--to=will@exomi.com \
--cc=caml-list@inria.fr \
--cc=sketerpot@chase3000.com \
/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