In F# I can define an add1
function
let add1 x = x + 1
I can then define an add2
as the add1
function called on itself
let add2 x = add1 (add1 x)
Or by composing the add1
function with itself
let add2 = add1 >> add1
I was trying to implement the lambda calculus combinators in F#, the first being Identity
let I x = x
I then tried to define the Identity
of Identity
let II = I >> I
But this caused the following compilation error:
Value restriction. The value 'II' has been inferred to have generic type val II : ('_a -> '_a) Either make the arguments to 'II' explicit or, if you do not intend for it to be generic, add a type annotation
I can however define it as
let II x = I (I x)
I'm new to F# and am curious why?