Hacker News new | past | comments | ask | show | jobs | submit login

Note that in OCaml, you can't get too screwy with point-free programming because of the value restriction. It is possible to compose functions in a point-free manner, but those functions themselves have to have points if you want them to be generic. Standard example:

    let last xs = List.fold_left (fun x y -> Some y) None xs
This is of type

    last : 'a list -> 'a option = <fun>
Neat, `'a` is generic. Let's η-reduce out the `xs` and make the function point-free (ignoring the lambda):

    let last = List.fold_left (fun x y -> Some y) None
This doesn't work the way that we want:

    last : '_weak1 list -> '_weak1 option = <fun>
The moment that we call this weakly polymorphic function, its type is fixed and is no longer generic. In the toplevel:

    # last [1;2;3];;
    - : int option = Some 3
    # last['x';'y';'z'];;
    Error: This expression has type char but an expression was expected of type
             int
Haskell, of course, is totally happy to let you do point-free mania with Kleisli arrows and all of the rest of it.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: