deriving-compat-0.5.6: Backports of GHC deriving extensions

Description

Exports functions to mechanically derive ReadClass, Read1, and Read2 instances.

Note: this is an internal module, and as such, the API presented here is not guaranteed to be stable, even between minor releases of this library.

Synopsis

# ReadClass

Generates a ReadClass instance declaration for the given data type or data family instance.

Like deriveRead, but takes a ReadOptions argument.

Generates a lambda expression which behaves like readsPrec (without requiring a ReadClass instance).

Generates a lambda expression which behaves like readPrec (without requiring a ReadClass instance).

# Read1

Generates 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

Generates 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

 ReadOptions FieldsuseReadPrec :: BoolIf True:Derived ReadClass instances will implement readPrec, not readsPrec, and will provide a default implementation of readListPrec in terms of readPrec.If built against base-4.10 or later, derived 'Read1'/'Read2' instances will implement 'liftReadPrec'/'liftReadPrec2', not 'liftReadsPrec'/'liftReadsPrec2', and will provide default implementations of 'liftReadListPrec'/'liftReadListPrec2' in terms of 'liftReadPrec'/'liftReadPrec2'. If built against an earlier version of base, derived 'Read1'/'Read2' instances are not affected, so they will act as if this flag were False.If False:Derived ReadClass instances will implement readsPrec.Derived Read1 instances will implement readsPrec1 (if built against transformers-0.4) or liftReadsPrec (otherwise). If not built against transformers-0.4, derived Read2 instances will implement liftReadsPrec2.It's generally a good idea to enable this option, since readPrec and friends are more efficient than readsPrec and friends, since the former use the efficient ReadPrec parser datatype while the latter use the slower, list-based ReadS type.
ReadOptions that favor readPrec over readsPrec.