Opened 6 years ago

Closed 6 years ago

#5483 closed bug (invalid)

Eta-reduced term has wrongly inferred monomorphic type

Reported by: darchon Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 7.2.1
Keywords: Cc:
Operating System: MacOS X Architecture: x86
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:



When creating a file with the following two definitions:

rowtotals xs = map sum xs
rowtotals'   = map sum

And loading this file in GHCi. Asking for the type of the two definitions gives:

*Main> :t rowtotals
rowtotals :: Num b => [[b]] -> [b]
*Main> :t rowtotals'
rowtotals' :: [[Integer]] -> [Integer]

Is this the expected behaviour? I would expect both to have the same polymorphic type.

Cheers, Christiaan

Change History (2)

comment:1 in reply to:  description Changed 6 years ago by darchon

It seems adding:

{-# LANGUAGE NoMonomorphismRestriction #-}

Will give both definitions the same inferred polymorphic type. But that still doesn't explain why 'Integer' was inferred out of all possible instances of 'Num'.

comment:2 Changed 6 years ago by simonpj

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.