[GHC] #10447: DeriveFoldable rejects instances with constraints in last argument of data type

GHC ghc-devs at haskell.org
Thu May 28 00:34:50 UTC 2015


#10447: DeriveFoldable rejects instances with constraints in last argument of data
type
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.10.1
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:  #8678             |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by shachaf):

 You expect that the `Foldable` instance for `data T2 a = (a ~ Int) => MkT2
 Int` give you the `Int` because there happens to be an `Int` equality
 constraint? That seems pretty unintuitive to me. What about e.g. `data E =
 E Int`, and `data A a = A E` vs. `data A a = (a ~ Int) => A E`, and then
 inlining E?

 I think Simon's examples are worth thinking about, and derived `Foldable`
 instances in the presence of equality constraints need some more
 justification. It's true that `Foldable` is the wild west of type classes,
 so parametricity doesn't give us the right answer like for `Functor`, but
 I don't expect it to just look for types that happen to be equal.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10447#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list