lens-3.8.7.3: 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

Has a `Name`

Methods

name :: Lens' t Name

Extract (or modify) the `Name` of something

Instances

HasName Name |
HasName TyVarBndr |
HasName Con |

class HasTypeVars t where

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

Methods

typeVarsEx :: Set Name -> Traversal' t Name

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

Provides substitution for types

Methods

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

Perform substitution for types

Instances

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

typeVars :: HasTypeVars t => Traversal' t Name

Traverse free type variables

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

Substitute using a map of names in for free type variables

conFields :: Traversal' Con StrictType

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

conNamedFields :: Traversal' Con VarStrictType

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