[Haskell-cafe] Type inference doesn't always calculate the most generic type?

Francesco Ariis fa-ml at ariis.it
Thu May 28 20:54:31 UTC 2015


On Thu, May 28, 2015 at 10:54:38PM +0200, Christophe Delord wrote:
> 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 just fired up ghci:

    λ> let mapabs = map abs
    λ> :t mapabs
    mapabs :: Num b => [b] -> [b]

ghc 7.10.1


More information about the Haskell-Cafe mailing list