#7487: Deriving Generic1 for a type containing Either -----------------------------+---------------------------------------------- Reporter: spl | Owner: dreixel Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.1 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Blockedby: Blocking: | Related: -----------------------------+---------------------------------------------- With the following code:
{{{ {-# LANGUAGE DeriveGeneric #-} import GHC.Generics data T a = C (Either Int a) deriving Generic1 }}} I get the error message: {{{ Main.hs:3:38: Can't make a derived instance of `Generic1 T': must not apply type constructors that cannot be represented with `Rep1' (such as `Either') to arguments that involve the last type parameter In the data declaration for `T' }}} But when I look at the instances of `Generic1`, I see the following (summarized): {{{ *Main> :i Generic1 ... instance Generic1 (Either a) -- Defined in `GHC.Generics' ... }}} So, it seems that `Either a` can be represented with `Rep1`. Consequently, the error message is a bit confusing. Similarly, I can define my own version of `Either` -- e.g. `data U a b = A a | B b deriving Generic1` -- replace `Either` with `U` and still get the message. I also get this problem using `U` as `data U a b = U a b deriving Generic1` but not with `T` as `data T a = C (Int, a) deriving Generic1`. Lastly, I try this: {{{ data T a = C (Either Int (T a)) deriving Generic1 }}} but the error is even stranger here: {{{ Main.hs:3:38: Can't make a derived instance of `Generic1 T': must not apply type constructors that cannot be represented with `Rep1' (such as `T') to arguments that involve the last type parameter In the data declaration for `T' }}} What's the general problem with these examples? * Can the error message be improved? * Can the deriving mechanism be extended for these types? I'm assuming I can write my own `Generic1` instance, though I haven't actually tried. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7487> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs