[GHC] #10447: DeriveFoldable rejects instances with constraints in last argument of data type
GHC
ghc-devs at haskell.org
Wed May 27 23:18:07 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 simonpj):
OK, but can I ask: can you say precisely what `Foldable` code you would
expect to get for these two data types?
{{{
data T1 a where
MkT1 :: (a~Int) => a -> T1 a
data T2 a where
MkT2 :: Int -> T2 Int
data T3 a where
MkT3 :: (a~Int) => a -> T3 Int
}}}
All three are equivalent. But I am guessing that you intend that they are
'''not equivalent''' to the "deriving `Foldable`" algorithm? If so, that
had better be clearly stated in the user manual.
(Regrettably, the user manual is silent on how `Foldable`, `Traversable`,
and `Functor` are generated. It'd be jolly good to have a wiki page that
explained the deriving algorithm;
[https://www.haskell.org/onlinereport/haskell2010/haskellch11.html#x18-18200011
here's how it's done for Eq/Ord etc].)
The documentation is probably the hard bit. The change to lift the
condition is pretty easy: look at `TcDeriv.cond_functorOK`. (This same
function actually handles `Traversable` and `Foldable`. A little
refactoring would be needed to distinguish the `Foldable` case, perhaps by
passing the class name instead of a boolean to the function.)
I'd be happy to review a patch.
Simon
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10447#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list