Search code examples
f#ocamlfunctor

F# changes to OCaml


F# is derived from OCaml, but what major items are missing or added? Specifically I'm curious as to whether the resources available for learning OCaml are also useful to someone who wants to learn F#.


Solution

  • The main differences are that F# does not support:

    • functors
    • OCaml-style objects
    • polymorphic variants
    • the camlp4/5 preprocessor or extension points (ppx)

    In addition, F# has a different syntax for labeled and optional parameters.

    In theory, OCaml programs that don't use these features can be compiled with F#. Learning OCaml is a perfectly reasonable introduction to F# (and vice versa, I'd imagine).

    The complete list of differences is here (note: archive.org replacement of dead link).