Generates a Read instance declaration for the given data type or data family instance.
Modulederiving-compat-0.6.8Haskell2010
Text.Read.Deriving
Exports functions to mechanically derive Read, Read1, and Read2 instances.
Note that upstream GHC does not have the ability to derive Read1 or Read2
instances, but since the functionality to derive Read extends very naturally
Read1 and Read2, the ability to derive the latter two classes is provided as a
convenience.
- 1 type
- 17 values
- Packagederiving-compat-0.6.8
- Exports18
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceDeriving.hs
Read
4 declarationsLike deriveRead, but takes a ReadOptions argument.
Generates a lambda expression which behaves like readPrec (without
requiring a Read instance).
Read1
6 declarationsGenerates a Read1 instance declaration for the given data type or data
family instance.
Like deriveRead1, but takes a ReadOptions argument.
Generates a lambda expression which behaves like liftReadsPrec (without
requiring a Read1 instance).
This function is not available with transformers-0.4.
Generates a lambda expression which behaves like liftReadPrec (without
requiring a Read1 instance).
This function is only available with base-4.10 or later.
Generates a lambda expression which behaves like readPrec1 (without
requiring a Read1 instance).
This function is only available with base-4.10 or later.
Generates a lambda expression which behaves like readsPrec1 (without
requiring a Read1 instance).
Read2
6 declarationsGenerates a Read2 instance declaration for the given data type or data
family instance.
This function is not available with transformers-0.4.
Like deriveRead2, but takes a ReadOptions argument.
This function is not available with transformers-0.4.
Generates a lambda expression which behaves like liftReadsPrec2 (without
requiring a Read2 instance).
This function is not available with transformers-0.4.
Generates a lambda expression which behaves like liftReadPrec2 (without
requiring a Read2 instance).
This function is only available with base-4.10 or later.
Generates a lambda expression which behaves like readPrec2 (without
requiring a Read2 instance).
This function is only available with base-4.10 or later.
Generates a lambda expression which behaves like readsPrec2 (without
requiring a Read2 instance).
This function is not available with transformers-0.4.
ReadOptions
2 declarationsOptions that further configure how the functions in Text.Read.Deriving should behave.
Constructors
ReadOptionsuseReadPrec :: BoolIf True:
Derived Read instances will implement
readPrec, not readsPrec, and will provide a default implementation ofreadListPrecin terms ofreadPrec.If built against
base-4.10or later, derivedRead1/Read2instances will implementliftReadPrec/liftReadPrec2, notliftReadsPrec/liftReadsPrec2, and will provide default implementations ofliftReadListPrec/liftReadListPrec2in terms ofliftReadPrec/liftReadPrec2. If built against an earlier version ofbase, derivedRead1/Read2instances are not affected, so they will act as if this flag were False.
If False:
Derived
Read1instances will implementreadsPrec1(if built againsttransformers-0.4) orliftReadsPrec(otherwise). If not built againsttransformers-0.4, derivedRead2instances will implementliftReadsPrec2.
It's generally a good idea to enable this option, since
readPrecand friends are more efficient than readsPrec and friends, since the former use the efficientReadPrecparser datatype while the latter use the slower, list-based ReadS type.
Instances4Eq, Ord, Read, Show
Eq ReadOptionsDefined in deriving-compat-0.6.8 · Text.Read.Deriving.InternalOrd ReadOptionsDefined in deriving-compat-0.6.8 · Text.Read.Deriving.InternalRead ReadOptionsDefined in deriving-compat-0.6.8 · Text.Read.Deriving.InternalShow ReadOptionsDefined in deriving-compat-0.6.8 · Text.Read.Deriving.Internal
ReadOptions that favor readPrec over readsPrec.
deriveRead limitations
0 declarationsBe aware of the following potential gotchas:
Type variables of kind
*are assumed to have Read constraints. Type variables of kind* -> *are assumed to haveRead1constraints. Type variables of kind* -> * -> *are assumed to haveRead2constraints. If this is not desirable, use makeReadsPrec or one of its cousins.The
Read1class had a different definition intransformers-0.4, and as a result, deriveRead1 implements different instances for thetransformers-0.4Read1than it otherwise does. Also, makeLiftReadsPrec andmakeLiftReadListare not available when this library is built againsttransformers-0.4, only 'makeReadsPrec1.The
Read2class is not available intransformers-0.4, and as a result, neither are Template Haskell functions that deal withRead2when this library is built againsttransformers-0.4.The
Read1andRead2classes have new methods (liftReadPrec/liftReadListPrecandliftReadPrec2/liftReadListPrec2, respectively) that were introduced inbase-4.10. For now, these methods are only defined when derivingRead1/Read2if built againstbase-4.10(untiltransformers-compatcatches up), and the correspondingmake-functions are also only available when built againstbase-4.10.