Hi David, ah yes, you're right of course. Interestingly, the Reason formatting tool reformats both of these into:

let g1 = (x) => {
  print_int(x);
  print_int
};

let g2 = (x) => {
  print_int(x);
  (y) => print_int(y)
};

I think it makes it very easy to tell that the latter just includes a redundant eta abstraction and can be simplified to the former.

Regards,

Yawar


On Wed, Dec 13, 2017 at 12:20 PM, David Allsopp <dra-news@metastack.com> wrote:
Yawar Amin wrote:
> On Wed, Dec 13, 2017 at 11:38 AM, Marshall <mailto:marshall@logical.net> wrote:
> > On Dec 13, 2017, at 4:37 AM, David Allsopp <mailto:dra-news@metastack.com> wrote:
> >
> > > In terms of why you might want to be "hiding" currying, or at least making it need
> > > less immediate explanation when learning the language, consider, for example,
> > > explaining the difference between:
> > >
> > > let f x y = print_int x; print_int y in
> > > f 42
> > >
> > > and
> > >
> > > let g x = print_int x; print_int in
> > > g 42

(code amended to give the functions different names)

> > Apart from ReasonML, this is interesting.  Why do these behave differently?
> > I don’t understand yet.
>
> In the second example, the second `print_int` never gets called.

No, both functions have the same type (int -> int -> unit) and if they're applied to two integers then each will print both of them to stdout. The difference is when they're partially applied - [f] prints nothing; [g] prints 42. It's slightly less unclear in lambda form:

let f =
  fun x ->
    fun y ->
      print_int x;
      print_int y

let g =
  fun x ->
    print_int x;
    fun y ->
      print_int y


David