
28 May
2015
28 May
'15
4:54 p.m.
Hello, I'm new here. Sorry if this question has already been asked. I have noticed something strange about type inference. Prelude> :t abs abs :: Num a => a -> a Prelude> let mapabs = map abs Prelude> :t mapabs mapabs :: [Integer] -> [Integer] Prelude> :t (map abs) (map abs) :: Num b => [b] -> [b] I think that "mapabs" and "map abs" should have the same generic type. In a program I can force the type like this: mapabs = map abs mapabs' :: (Num a) => [a] -> [a] mapabs' = map abs but mapabs still have the type [Integer] -> [Integer] Are there any reason for this? Regards, Christophe Delord.