Ticket #5736 (closed bug: invalid)

Opened 17 months ago

Last modified 17 months ago

Possible regression with functional dependencies

Reported by: magnus Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 7.2.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

The following program typechecks in GHC-7.0.4, but not in 6.12.3, 7.2.2 or 7.5.20111229:

{-# LANGUAGE FunctionalDependencies, MultiParamTypeClasses, 
  FlexibleInstances, UndecidableInstances, TypeFamilies #-}

class C a b | a -> b where
  c :: a -> b

instance C b b where
  c = undefined

instance C Bool b where
  c = undefined

m :: Int
m = c True

7.5.20111229 says

    Couldn't match type `Bool' with `Int'
    When using functional dependencies to combine
      C b b,
        arising from the dependency `a -> b'
        in the instance declaration at Test.hs:7:10
      C Bool Int, arising from a use of `c' at Test.hs:14:5
    In the expression: c True
    In an equation for `m': m = c True

Was I just lucky that this worked in 7.0.4, or is it a true regression?

Change History

Changed 17 months ago by simonpj

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

I think 7.0.4 had a bug. Consider

  • 'a' determines 'b'. So if two instances have matching a's they must have matching b's.
  • The first intstance says that the second parameter must always match the first.
  • But it doesn't in the second instance declaration.

This is one of the rules in Mark Jones's original paper.

Simon

Changed 17 months ago by magnus

That makes sense, thanks for the explanation!

Note: See TracTickets for help on using tickets.