[Haskell-cafe] Is generic information dumpable?

Bas van Dijk v.dijk.bas at gmail.com
Fri Nov 4 00:26:04 CET 2011


2011/11/3 José Pedro Magalhães <jpm at cs.uu.nl>:
> "-ddump-deriv" will print (most of) it.

But it doesn't print the most useful piece of information: the
definition of Rep.

It would be great if this could be added.

Currently when I have a type that I want to know the Rep of, say:

data Foo = Bar Int
         | Boo {hello :: String}
           deriving Generic

I just convert it to a Rep and show it:

err = show $ from $ Boo "World"

However Reps don't have Show instances so GHC complains:

No instance for
  (Show (D1 D1Foo (   C1 C1_0Foo (S1 NoSelector (Rec0 Int))
                  :+: C1 C1_1Foo (S1 S1_1_0Foo (Rec0 String))
                  )
         x0
        )
  )
  arising from a use of `show'

And there you go. This is the only time when I'm happy to see an error
message :-)

Bas



More information about the Haskell-Cafe mailing list