lens-4.19.2: Lenses, Folds and Traversals
Copyright(C) 2012-2016 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
PortabilityTemplateHaskell
Safe HaskellTrustworthy
LanguageHaskell2010

Language.Haskell.TH.Lens

Description

Lenses, Prisms, and Traversals for working with Template Haskell.

Beware that the API offered in this module is subject to change, as it mirrors the API exposed by the template-haskell package, which frequently changes between different releases of GHC. An effort is made to identify the functions in this module which have different type signatures when compiled with different versions of template-haskell.

Synopsis

Traversals

class HasName t where #

Has a Name

Methods

name :: Lens' t Name #

Extract (or modify) the Name of something

Instances

Instances details
HasName Name # 
Instance details

Defined in Language.Haskell.TH.Lens

Methods

name :: Lens' Name Name #

HasName InjectivityAnn # 
Instance details

Defined in Language.Haskell.TH.Lens

HasName TypeFamilyHead # 
Instance details

Defined in Language.Haskell.TH.Lens

HasName Foreign # 
Instance details

Defined in Language.Haskell.TH.Lens

Methods

name :: Lens' Foreign Name #

HasName RuleBndr # 
Instance details

Defined in Language.Haskell.TH.Lens

HasName Con #

On template-haskell-2.11.0.0 or later, if a GadtC or RecGadtC has multiple Names, the leftmost Name will be chosen.

Instance details

Defined in Language.Haskell.TH.Lens

Methods

name :: Lens' Con Name #

HasName TyVarBndr # 
Instance details

Defined in Language.Haskell.TH.Lens

class HasTypes t where #

Contains some amount of Types inside

Methods

types :: Traversal' t Type #

Traverse all the types

Instances

Instances details
HasTypes Type # 
Instance details

Defined in Language.Haskell.TH.Lens

HasTypes TySynEqn # 
Instance details

Defined in Language.Haskell.TH.Lens

HasTypes Foreign # 
Instance details

Defined in Language.Haskell.TH.Lens

HasTypes Con # 
Instance details

Defined in Language.Haskell.TH.Lens

HasTypes t => HasTypes [t] # 
Instance details

Defined in Language.Haskell.TH.Lens

Methods

types :: Traversal' [t] Type #

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

Instances details
HasTypeVars Type # 
Instance details

Defined in Language.Haskell.TH.Lens

HasTypeVars Name # 
Instance details

Defined in Language.Haskell.TH.Lens

HasTypeVars Con # 
Instance details

Defined in Language.Haskell.TH.Lens

HasTypeVars TyVarBndr # 
Instance details

Defined in Language.Haskell.TH.Lens

HasTypeVars t => HasTypeVars [t] # 
Instance details

Defined in Language.Haskell.TH.Lens

Methods

typeVarsEx :: Set Name -> Traversal' [t] Name #

HasTypeVars t => HasTypeVars (Maybe t) # 
Instance details

Defined in Language.Haskell.TH.Lens

class SubstType t where #

Provides substitution for types

Methods

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

Perform substitution for types

Instances

Instances details
SubstType Type # 
Instance details

Defined in Language.Haskell.TH.Lens

Methods

substType :: Map Name Type -> Type -> Type #

SubstType t => SubstType [t] # 
Instance details

Defined in Language.Haskell.TH.Lens

Methods

substType :: Map Name Type -> [t] -> [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 BangType #

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

conFields :: Traversal' Con BangType   -- template-haskell-2.11+
conFields :: Traversal' Con StrictType -- Earlier versions

conNamedFields :: Traversal' Con VarBangType #

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

conNamedFields :: Traversal' Con VarBangType   -- template-haskell-2.11+
conNamedFields :: Traversal' Con VarStrictType -- Earlier versions

Lenses

Loc Lenses

FunDep Lenses

Match Lenses

Fixity Lenses

Clause Lenses

FieldExp Lenses

FieldPat Lenses

TySynEqn Lenses

InjectivityAnn Lenses

TypeFamilyHead Lenses

Bang Lenses

DerivClause Lenses

Prisms

Info Prisms

_ClassOpI :: Prism' Info (Name, Type, ParentName) #

_ClassOpI :: Prism' Info (Name, Type, ParentName)         -- template-haskell-2.11+
_ClassOpI :: Prism' Info (Name, Type, ParentName, Fixity) -- template-haskell-2.8 through 2.10
_ClassOpI :: Prism' Info (Name, Type, Name,       Fixity) -- Earlier versions

_DataConI :: Prism' Info (Name, Type, ParentName) #

_DataConI :: Prism' Info (Name, Type, ParentName)         -- template-haskell-2.11+
_DataConI :: Prism' Info (Name, Type, ParentName, Fixity) -- template-haskell-2.8 through 2.10
_DataConI :: Prism' Info (Name, Type, Name,       Fixity) -- Earlier versions

_VarI :: Prism' Info (Name, Type, Maybe Dec) #

_VarI :: Prism' Info (Name, Type, Maybe Dec)         -- template-haskell-2.11+
_VarI :: Prism' Info (Name, Type, Maybe Dec, Fixity) -- Earlier versions

Dec Prisms

_DataD :: DataPrism' [TyVarBndr] [Con] #

_DataD :: Prism' Dec (Cxt, Name, [TyVarBndr], Maybe Kind, [Con], [DerivClause]) -- template-haskell-2.12+
_DataD :: Prism' Dec (Cxt, Name, [Type],      Maybe Kind, [Con], Cxt)           -- template-haskell-2.11
_DataD :: Prism' Dec (Cxt, Name, [Type],                  [Con], [Name])        -- Earlier versions

_NewtypeD :: DataPrism' [TyVarBndr] Con #

_NewtypeD :: Prism' Dec (Cxt, Name, [TyVarBndr], Maybe Kind, Con, [DerivClause]) -- template-haskell-2.12+
_NewtypeD :: Prism' Dec (Cxt, Name, [Type],      Maybe Kind, Con, Cxt)           -- template-haskell-2.11
_NewtypeD :: Prism' Dec (Cxt, Name, [Type],                  Con, [Name])        -- Earlier versions

_InstanceD :: Prism' Dec (Maybe Overlap, Cxt, Type, [Dec]) #

_InstanceD :: Prism' Dec (Maybe Overlap, Cxt, Type, [Dec]) -- template-haskell-2.11+
_InstanceD :: Prism' Dec                (Cxt, Type, [Dec]) -- Earlier versions

_DataInstD :: Prism' Dec (Cxt, Maybe [TyVarBndr], Type, Maybe Kind, [Con], [DerivClause]) #

_DataInstD :: Prism' Dec (Cxt, Maybe [TyVarBndr], Type, Maybe Kind, [Con], [DerivClause]) -- template-haskell-2.15+
_DataInstD :: Prism' Dec (Cxt, Name, [Type],            Maybe Kind, [Con], [DerivClause]) -- template-haskell-2.12 through 2.14
_DataInstD :: Prism' Dec (Cxt, Name, [Type],            Maybe Kind, [Con], Cxt)           -- template-haskell-2.11
_DataInstD :: Prism' Dec (Cxt, Name, [Type],                        [Con], [Name])        -- Earlier versions

_NewtypeInstD :: Prism' Dec (Cxt, Maybe [TyVarBndr], Type, Maybe Kind, Con, [DerivClause]) #

_NewtypeInstD :: Prism' Dec (Cxt, Maybe [TyVarBndr], Type, Maybe Kind, Con, [DerivClause]) -- template-haskell-2.15+
_NewtypeInstD :: Prism' Dec (Cxt, Name, [Type],            Maybe Kind, Con, [DerivClause]) -- template-haskell-2.12 through 2.14
_NewtypeInstD :: Prism' Dec (Cxt, Name, [Type],            Maybe Kind, Con, Cxt)           -- template-haskell-2.11
_NewtypeInstD :: Prism' Dec (Cxt, Name, [Type],                        Con, [Name])        -- Earlier versions

_TySynInstD :: Prism' Dec TySynEqn #

_TySynInstD :: Prism' Dec TySynEqn             -- template-haskell-2.15+
_TySynInstD :: Prism' Dec (Name, TySynEqn)     -- template-haskell-2.9 through 2.14
_TySynInstD :: Prism' Dec (Name, [Type], Type) -- Earlier versions

_StandaloneDerivD :: Prism' Dec (Maybe DerivStrategy, Cxt, Type) #

_StandaloneDerivD :: Prism' Dec (Maybe DerivStrategy, Cxt, Type) -- template-haskell-2.12+
_StandaloneDerivD :: Prism' Dec                      (Cxt, Type) -- Earlier versions

PatSynDir Prisms

PatSynArgs Prisms

Con Prisms

_NormalC :: Prism' Con (Name, [BangType]) #

_NormalC :: Prism' Con (Name, [BangType])   -- template-haskell-2.11+
_NormalC :: Prism' Con (Name, [StrictType]) -- Earlier versions

_RecC :: Prism' Con (Name, [VarBangType]) #

_RecC :: Prism' Con (Name, [VarBangType])   -- template-haskell-2.11+
_RecC :: Prism' Con (Name, [VarStrictType]) -- Earlier versions

_InfixC :: Prism' Con (BangType, Name, BangType) #

_InfixC :: Prism' Con (BangType,   Name, BangType)   -- template-haskell-2.11+
_InfixC :: Prism' Con (StrictType, Name, StrictType) -- Earlier versions

Overlap Prisms

SourceUnpackedness Prisms

SourceStrictness Prisms

DecidedStrictness Prisms

Foreign Prisms

Callconv Prisms

Safety Prisms

Pragma Prisms

_InlineP :: Prism' Pragma (Name, Inline, RuleMatch, Phases) #

_InlineP :: Prism' Pragma (Name, Inline, RuleMatch, Phases) -- template-haskell-2.8+
_InlineP :: Prism' Pragma (Name, Inline)                    -- Earlier versions

_SpecialiseP :: Prism' Pragma (Name, Type, Maybe Inline, Phases) #

_SpecialiseP :: Prism' Pragma (Name, Type, Maybe Inline, Phases) -- template-haskell-2.8+
_SpecialiseP :: Prism' Pragma (Name, Type, Maybe InlineSpec)     -- Earlier versions

_RuleP :: Prism' Pragma (String, Maybe [TyVarBndr], [RuleBndr], Exp, Exp, Phases) #

_RuleP :: Prism' Pragma (String, Maybe [TyVarBndr], [RuleBndr], Exp, Exp, Phases) -- template-haskell-2.15+
_RuleP :: Prism' Pragma (String,                    [RuleBndr], Exp, Exp, Phases) -- Earlier versions

Inline Prisms

RuleMatch Prisms

Phases Prisms

RuleBndr Prisms

AnnTarget Prisms

FunDep Prisms TODO make a lens

FixityDirection Prisms

Exp Prisms

_TupE :: Prism' Exp [Maybe Exp] #

_TupE :: Prism' Exp [Maybe Exp] -- template-haskell-2.16+
_TupE :: Prism' Exp [Exp]       -- Earlier versions

_UnboxedTupE :: Prism' Exp [Maybe Exp] #

_UnboxedTupE :: Prism' Exp [Maybe Exp] -- template-haskell-2.16+
_UnboxedTupE :: Prism' Exp [Exp]       -- Earlier versions

Body Prisms

Guard Prisms

Stmt Prisms

Range Prisms

Lit Prisms

Pat Prisms

Type Prisms

TyVarBndr Prisms

FamilyResultSig Prisms

TyLit Prisms

Role Prisms

DerivStrategy Prisms