RE: [Haskell] deriving Show for GADT?
Yes, indeed, see http://hackage.haskell.org/trac/ghc/ticket/3012 Incidentally, the main Haskell list isn't the right place for GHC-specific questions. glasgow-haskell-users@haskell.org is the place Simon | -Original Message- | From: haskell-boun...@haskell.org [mailto:haskell-boun...@haskell.org] On Behalf Of | Norman Ramsey | Sent: 14 April 2009 05:28 | To: hask...@haskell.org | Subject: [Haskell] deriving Show for GADT? | | 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 | hask...@haskell.org | http://www.haskell.org/mailman/listinfo/haskell ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell] deriving Show for GADT?
If it's easy I think just generating the code and let the type checker report any problems would be a great thing for standalone deriving. -- Lennart On Tue, Apr 14, 2009 at 10:10 AM, Simon Peyton-Jones simo...@microsoft.com wrote: Yes, indeed, see http://hackage.haskell.org/trac/ghc/ticket/3012 Incidentally, the main Haskell list isn't the right place for GHC-specific questions. glasgow-haskell-us...@haskell.org is the place Simon | -Original Message- | From: haskell-boun...@haskell.org [mailto:haskell-boun...@haskell.org] On Behalf Of | Norman Ramsey | Sent: 14 April 2009 05:28 | To: hask...@haskell.org | Subject: [Haskell] deriving Show for GADT? | | 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 | hask...@haskell.org | http://www.haskell.org/mailman/listinfo/haskell ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell] deriving Show for GADT?
You might be able to write some Template Haskell to derive the Show instance. 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) do? -- ryan On Mon, Apr 13, 2009 at 9:28 PM, Norman Ramsey n...@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@haskell.org http://www.haskell.org/mailman/listinfo/haskell ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] deriving Show for GADT?
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. -Edward Kmett On Tue, Apr 14, 2009 at 2:03 AM, Ryan Ingram ryani.s...@gmail.com wrote: You might be able to write some Template Haskell to derive the Show instance. 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) do? -- ryan On Mon, Apr 13, 2009 at 9:28 PM, Norman Ramsey n...@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@haskell.org http://www.haskell.org/mailman/listinfo/haskell ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] deriving Show for GADT?
Unfortunately, this isn't supported at present. --Ben On 14 Apr 2009, at 05:28, Norman Ramsey 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@haskell.org http://www.haskell.org/mailman/listinfo/haskell ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell