[GHC] #10447: DeriveFoldable rejects instances with constraints in last argument of data type
GHC
ghc-devs at haskell.org
Mon Jun 1 18:57:20 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 dolio):
Yeah, I'm not a big fan (at the moment) of having equality constraints and
the like pick up fields that aren't syntactically identical. For instance:
{{{
data Foo b a where
MkFoo :: (T b ~ a) => a -> b -> Int -> Foo b a
deriving Foldable
}}}
Now if `T b` reduces to `Int`, we fold over the first ''and'' third
argument, but if it doesn't, we only fold over the first (because we can't
do anything else)? I could probably agree with having it succeed and
always fold over the first field, because it's syntactically an `a`. But I
feel like that should be the default behavior, not trying to deduce things
from the constraints.
Also consider:
{{{
class (b ~ Int) => Foo a b where ...
class Foo a b => Bar a b where ...
data Quux a b where
MkQ :: Bar a b => Int -> a -> b -> Quux a b
}}}
Does this pick up the `Int` because if we trace back from `Bar a b` we get
`b ~ Int`? What about more complicated examples?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10447#comment:16>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list