text-show-0.3.0.0: Efficient conversion of values into Text

Copyright(C) 2014 Ryan Scott
LicenseBSD-style (see the file LICENSE)
MaintainerRyan Scott
StabilityExperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell98

Text.Show.Text.TH

Description

Exports deriveShow, which automatically derives a Show instance for a data type or newtype. You need to enable the TemplateHaskell language extension in order to use deriveShow.

As an example:

{-# LANGUAGE TemplateHaskell #-}
import Text.Show.Text.TH (deriveShow)

data D a = Nullary
         | Unary Int
         | Product String Char a
         | Record { testOne   :: Double
                  , testTwo   :: Bool
                  , testThree :: D a
                  }
$(deriveShow ''D)

D now has a Show instance equivalent to that which would be generated by a deriving Show clause.

Note that at the moment, deriveShow does not support data families, so it is impossible to use deriveShow with data instances or newtype instances.

Synopsis

Documentation

deriveShow :: Name -> Q [Dec] Source

Generates a Show instance declaration for the given data type or newtype.