Opened 3 years ago

Closed 3 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 Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Hi,

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 3 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 3 years ago by simonpj

  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.