0

I was learning anonymous functions in haskell.

mTH3 x = (\y -> \z -> x*y*z)

The type signature for this comes out to be

*Main> :t mTH3
mTH3 :: Num a => a -> a -> a -> a    

Whereas for this function

mTH4 = (\x -> \y -> \z -> x*y*z)  

It comes out to be

*Main> :t mTH4
mTH4 :: Integer -> Integer -> Integer -> Integer

What is the reason of difference between them. Why isn't the type signature for second function same as first. If I try to define type signature of the second function like this :

mTH4 :: Num a => a -> a -> a -> a
mTH4 = (\x -> \y -> \z -> x*y*z)  

Then the output is same as the mTH3 function.

formatkaka
  • 1,278
  • 3
  • 13
  • 27
  • I just tried it in `ghci` and they have the same signature `Num a => a -> a -> a -> a`. – zoran119 Jul 09 '16 at 12:46
  • @zoran119 GHCi behaves differently from compiling with ghc, by default. See the question linked above by chepner. – Bakuriu Jul 09 '16 at 13:16

0 Answers0