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

Tikhon Jelvis tikhon at jelv.is
Thu May 28 21:01:50 UTC 2015


The monomorphism restriction is turned off by default in ghci since version
7.8.1, so you'll see this behavior with newer versions of GHC and the
original behavior with older ones.

On Thu, May 28, 2015 at 1:54 PM, Francesco Ariis <fa-ml at ariis.it> wrote:

> 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
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150528/fe543759/attachment.html>


More information about the Haskell-Cafe mailing list