[Haskell] deriving Show for GADT?
ekmett at gmail.com
Tue Apr 14 10:27:50 EDT 2009
I seem to recall Matt Morrow having some code lying around for automatically
generating such instances using haskell-src-exts. I wonder how hard it would
be to adapt to Template Haskell.
On Tue, Apr 14, 2009 at 2:03 AM, Ryan Ingram <ryani.spam at gmail.com> wrote:
> You might be able to write some Template Haskell to derive the Show
> It's a bit tricky, because there are some types which can't have Show
> derived, such as:
> data Foo where
> Broken :: a -> Foo
> What should
> show (Broken id)
> -- ryan
> On Mon, Apr 13, 2009 at 9:28 PM, Norman Ramsey <nr at cs.tufts.edu> wrote:
> > I've got a fairly large GADT for which I wished to use
> > deriving (Show)
> > but I got a mysterious error message:
> > Exp.hs:13:11:
> > Can't make a derived instance of `Show (Exp a)'
> > (`Exp' has non-Haskell-98 constructor(s))
> > In the data type declaration for `Exp'
> > This is from GHC. Does anybody know a compiler option or other trick
> > that will coax the compiler into producing a Show instance.
> > (I know I can write one by hand, but I'd rather not bother.)
> > Norman
> > _______________________________________________
> > Haskell mailing list
> > Haskell at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell
> Haskell mailing list
> Haskell at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell