Search code examples
functional-programmingsmlnj

SML/NJ - the "fun act(f,x) = f(x) ;" signature


Declare on the follow function -

fun act(f,x) = f(x);

Makes the signature -

val act = fn : ('a -> 'b) * 'a -> 'b

What does ('a -> 'b) * 'a -> 'b means ?


Solution

  • It means that act is a function that takes a pair (2-tuple)

    ('a -> 'b) * 'a
    

    where the first element is a function from 'a to 'b, and the second is a thing of type 'a.
    It returns a thing of type 'b.