Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] simple typing question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pixel <pixel@m...>
Subject: Re: [Caml-list] simple typing question
Pierre Weis <pierre.weis@inria.fr> writes:

> > what about changing the semantic of partial application, restoring
> > eta-equivalence: a function is not evaluated unless every arguments
> > are given:
> 
> Could you precisely state this notion ? In the presence of higher
> order functions and imperative features, this does not appear to be
> simple and evident to me...

well, wrap every functions:

# let make_toggle_ () =
    let r = ref [] in fun x -> let old = !r in r := x; old

with

# let make_toggle a b = make_toggle_ a b

based on the number of parameters of functions (given by the type).

This disables evaluation of a function until every parameters are
provided.


The program transformation involved is something like:
  let t = foo in fun x -> bar
gives
  fun x -> let t = foo in bar

ie
  (fun t -> (fun x -> bar)) foo
gives
  (fun x -> (fun t -> bar) foo)

> (Let alone recursive functions and types as in
> $ ocaml -rectypes
> # let rec print x = print_int x; print;;
> val print : int -> 'a as 'a = <fun>
> # print 1 2 3;;
> 123- : int -> 'a as 'a = <fun>

of course it doesn't work nicely for this since the "number of
parameters" doesn't mean anything, so you can't know when you can
start evaluating.
-------------------
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