lens-3.10: Lenses, Folds and Traversals

Portability | TemplateHaskell
Stability | experimental
Maintainer | Edward Kmett <ekmett@gmail.com>
Safe Haskell | Trustworthy

Language.Haskell.TH.Lens

Description

Lenses and Traversals for working with Template Haskell

Synopsis

- class HasName t where
  - name :: Lens' t Name
- class HasTypeVars t where
  - typeVarsEx :: Set Name -> Traversal' t Name
- class SubstType t where
  - substType :: Map Name Type -> t -> t
- typeVars :: HasTypeVars t => Traversal' t Name
- substTypeVars :: HasTypeVars t => Map Name Name -> t -> t
- conFields :: Traversal' Con StrictType
- conNamedFields :: Traversal' Con VarStrictType

# Documentation

class HasName t where Source

Has a `Name`

Methods

name :: Lens' t Name Source

Extract (or modify) the `Name` of something

Instances

HasName Name |
HasName TyVarBndr |
HasName Con |

class HasTypeVars t where Source

Provides for the extraction of free type variables, and alpha renaming.

Methods

typeVarsEx :: Set Name -> Traversal' t Name Source

When performing substitution into this traversal you're not allowed to substitute in a name that is bound internally or you'll violate the `Traversal` laws, when in doubt generate your names with `newName`.

Instances

HasTypeVars Type |
HasTypeVars Name |
HasTypeVars Pred |
HasTypeVars TyVarBndr |
HasTypeVars Con |
HasTypeVars t => HasTypeVars [t] |

class SubstType t where Source

Provides substitution for types

Methods

substType :: Map Name Type -> t -> tSource

Perform substitution for types

Instances

SubstType Type |
SubstType Pred |
SubstType t => SubstType [t] |

typeVars :: HasTypeVars t => Traversal' t Name Source

Traverse free type variables

substTypeVars :: HasTypeVars t => Map Name Name -> t -> tSource

Substitute using a map of names in for free type variables

conFields :: Traversal' Con StrictType Source

Provides a `Traversal` of the types of each field of a constructor.

conNamedFields :: Traversal' Con VarStrictType Source

`Traversal` of the types of the named fields of a constructor.