Search code examples
haskelltypestype-signature

For Haskell type signature, like babel :: a -> b -> c, is c the return type?


why doesn't Haskell use some kind of special format to reflect this, or -> c can be understood in another way?


Solution

  • Haskell uses a concept called currying, which means there are only single parameter functions, and multiple parameter functions are just functions returning another functions, with the previous parameter "baked in", until all the parameters are filled in.

    so

    add :: Int -> Int -> Int
    add x y = x + y
    

    is equivalent to

    add :: Int -> (Int -> Int)
    add = \x -> \y -> x + y