Browse thread
[Caml-list] Recursive apply function
-
Peter Scott
- Aleksey Nogin
- Brian Hurt
- Ville-Pertti Keinonen
[
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: | Ville-Pertti Keinonen <will@e...> |
| Subject: | Re: [Caml-list] Recursive apply function |
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