
On Sun, Aug 17, 2014 at 12:08:57PM +0100, Karolis Velicka wrote:
In that case, can you elaborate please? I don't see how this is different to making the record itself an instance if Show.
If by "no difference" you mean "equivalent output", I guess we can ditch
Haskell and write programs in Basic.
What Martin is asking for is how you could implement such a feature if
something like |deriving (Show)| weren't there.
On 17 Aug 2014 10:44, "martin"
Right, but this is merely a coincidence.
What I wanted is a way to show a value of a record, where all fields are instances of Show.
Haskell itself is able to do this (and it even figures out the accessors, which I am not even asking for).
Martin, as far as I know this is not possible in standard ^Haskell 2010^ [1]. To perform this kind of magic people use ^Template Haskell^ [2], which is, in so many words, a meta programming extension for GHC; with it you can handle and go-back-and-forth between Concrete Syntax and the Abstract Syntax Tree. Template Haskell isn't type safe and that goes "against the grain" of Haskell-the-language itself, I suppose (for sure it goes against mine); it is used in some popular libraries (e.g. lens, yesod). [1] http://www.haskell.org/onlinereport/haskell2010/ [2] http://www.haskell.org/haskellwiki/Template_Haskell