Ticket #2618 (closed bug: invalid)

Opened 5 years ago

Last modified 5 years ago

Order is relevant when matching signature contexts of a mutually recursive group

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

Description

The Following code

f :: (Show a, Eq a) => a -> String
f x = show x `const` g x

g :: (Eq a,Show a) => a -> Bool
g x = x==x `const` f x

gives this error:

    Couldn't match expected type `Eq a' against inferred type `Show a1'
    When matching the contexts of the signatures for
      f :: forall a. (Show a, Eq a) => a -> String
      g :: forall a. (Eq a, Show a) => a -> Bool
    The signature contexts in a mutually recursive group should all be identical
    When generalising the type(s) for f, g
Failed, modules loaded: none.

but it compiles fine if i swap Show and Eq in the context of either f or g. The order of typeclass constraints usually doesn't matter so it's very surprising that it does here.

Change History

Changed 5 years ago by igloo

  • difficulty set to Unknown
  • milestone set to 6.10.1

I'm not sure off the top of my head if your example is supposed to work in H98, but if you use -XRelaxedPolyRec then it is accepted.

Changed 5 years ago by simonpj

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

It's part of the Haskell 98 spec; see the last sentence of Section 4.5.2  http://haskell.org/onlinereport/decls.html#generalization

As Ian says, the -XRelaxedPolyRec flag lifts this restriction.

I'll close the bug as invalid. But don't let that discourage you from reporting bugs.

Simon

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.