Ticket #2854 (closed bug: duplicate)

Opened 4 years ago

Last modified 4 years ago

Extended defaulting rules not used for super classes

Reported by: guest Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.10.1
Keywords: Cc: lennart@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Consider the following module

{-# LANGUAGE ExtendedDefaultRules #-}
module Bug4 where

class (Num a) => C a where
    f :: a -> a

instance C Integer where
    f = (+1)

x = show (f 5)

The type of x is

x :: (C a) => String

and since a is ambiguous the defaulting rules should be used. Since Num is a superclass of C the type variable should be defaulted to Integer. But instead we get an error.

Removing the Num superclass of C makes it work, since the type of x is

x ::: (Num a, C a) => String

and the defaulting kicks in as expected.

Change History

Changed 4 years ago by guest

  • cc lennart@… added

Changed 4 years ago by simonpj

  • status changed from new to closed
  • difficulty set to Unknown
  • resolution set to duplicate

Hmm, well that does seem reasonable. But it depends on how we ultimately reformulate the -XExtendedDefaultRules rules (#2641). So I'll close this ticket to leave #2641 as the ticket where we figure out what to do for extended default rules. Simon

Note: See TracTickets for help on using tickets.