Safe Haskell | None |
---|---|

Language | Haskell2010 |

Record types in Haskell can be made lazy through lazy pattern
matching. This module offers functions for making them lazy
*generically*. Whereas Data.Lazify.`genericLazify`

uses `Lazifiable`

to lazify under a `newtype`

, the
functions in this module expect the underlying type of a `newtype`

to be `Generic`

as well.

## Synopsis

- class GenericLazifiable a where
- lazifyGeneric :: a -> a

- ($~) :: forall rep a (b :: TYPE rep). GenericLazifiable a => (a -> b) -> a -> b

# Documentation

class GenericLazifiable a where Source #

This class is intended to be used primarily with the
generic instance given in this module. However, users are free
to write `{-# OVERLAPPING #-}`

instances whenever necessary.

lazifyGeneric :: a -> a Source #

Lazify a record using its generic representation.

Note that newtypes are treated specially: a newtype is lazified
by lazifying its *underlying* type.

#### Instances

($~) :: forall rep a (b :: TYPE rep). GenericLazifiable a => (a -> b) -> a -> b Source #

Apply a function to a lazified value.

Note to users of `TypeApplications`

: For GHC >= 9.0.1, the representation
is marked as inferred. Before that, doing so is impossible and the
representation must be passed as the first type argument. I'm sorry.