I wrote a function add\' in test.hs:
add\' = \\x y -> x + y
Then I loaded test.hs in GHCi (versio
You have hit upon the dreaded monomorphism restriction. Monomorphism restriction makes the type signature of your function specialized to a single type. You can turn off that using the extension NoMonomorphismRestriction:
{-# LANGUAGE NoMonomorphismRestriction #-}
add1 = \x y -> x + y
add2 = \x -> \y -> x + y
add3 x y = x + y
And then when you load the types in ghci they will be:
λ> :t add1
add1 :: Num a => a -> a -> a
λ> :t add2
add2 :: Num a => a -> a -> a
λ> :t add3
add3 :: Num a => a -> a -> a