F#: Function Signature

I always forget how to write Haskell-like function signatures in F#.

type AddOne = int -> int
let addOne : AddOne =
    fun i ->
        i + 1

screenshot with signature2

You can think of AddOne as an interface in OO-languages, for functions. Basically, it’s a (C#) delegate, with less boilerplate.

The beauty of it: I can model my domain with AddOne, without caring about the implementation of addOne.

comments powered by Disqus