lens-5.2.3: 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 Source #

Has a Name

Methods

name :: Lens' t Name Source #

Extract (or modify) the Name of something

Instances

Instances details
HasName Con Source #

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

HasName Foreign Source # 
Instance details

Defined in Language.Haskell.TH.Lens

HasName InjectivityAnn Source # 
Instance details

Defined in Language.Haskell.TH.Lens

HasName Name Source # 
Instance details

Defined in Language.Haskell.TH.Lens

HasName RuleBndr Source # 
Instance details

Defined in Language.Haskell.TH.Lens

HasName TypeFamilyHead Source # 
Instance details

Defined in Language.Haskell.TH.Lens

HasName (TyVarBndr_ flag) Source # 
Instance details

Defined in Language.Haskell.TH.Lens

Methods

name :: Lens' (TyVarBndr_ flag) Name Source #

class HasTypes t where Source #

Contains some amount of Types inside

Methods

types :: Traversal' t Type Source #

Traverse all the types

Instances

Instances details
HasTypes Con Source # 
Instance details

Defined in Language.Haskell.TH.Lens

HasTypes Foreign Source # 
Instance details

Defined in Language.Haskell.TH.Lens

HasTypes TySynEqn Source # 
Instance details

Defined in Language.Haskell.TH.Lens

HasTypes Type Source # 
Instance details

Defined in Language.Haskell.TH.Lens

HasTypes t => HasTypes [t] Source # 
Instance details

Defined in Language.Haskell.TH.Lens

Methods

types :: Traversal' [t] Type Source #

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

Instances details
HasTypeVars Con Source # 
Instance details

Defined in Language.Haskell.TH.Lens

HasTypeVars Name Source # 
Instance details

Defined in Language.Haskell.TH.Lens

HasTypeVars Type Source # 
Instance details

Defined in Language.Haskell.TH.Lens

HasTypeVars (TyVarBndr_ flag) Source # 
Instance details

Defined in Language.Haskell.TH.Lens

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

Defined in Language.Haskell.TH.Lens

HasTypeVars t => HasTypeVars [t] Source # 
Instance details

Defined in Language.Haskell.TH.Lens

class SubstType t where Source #

Provides substitution for types

Methods

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

Perform substitution for types

Instances

Instances details
SubstType Type Source # 
Instance details

Defined in Language.Haskell.TH.Lens

SubstType t => SubstType [t] Source # 
Instance details

Defined in Language.Haskell.TH.Lens

Methods

substType :: Map Name Type -> [t] -> [t] Source #

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

Traverse free type variables

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

Substitute using a map of names in for free type variables

conFields :: Traversal' Con BangType Source #

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

conNamedFields :: Traversal' Con VarBangType Source #

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

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

Dec Prisms

_DataD :: DataPrism' [TyVarBndrVis] [Con] Source #

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

_NewtypeD :: DataPrism' [TyVarBndrVis] Con Source #

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

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

_DataInstD :: Prism' Dec (Cxt, Maybe [TyVarBndrUnit], 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)           -- Earlier versions

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

_NewtypeInstD :: Prism' Dec (Cxt, Maybe [TyVarBndrUnit], 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)           -- Earlier versions

_TySynInstD :: Prism' Dec TySynEqn Source #

_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) Source #

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

PatSynDir Prisms

PatSynArgs Prisms

Con Prisms

Overlap Prisms

SourceUnpackedness Prisms

SourceStrictness Prisms

DecidedStrictness Prisms

Foreign Prisms

Callconv Prisms

Safety Prisms

Pragma Prisms

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

_RuleP :: Prism' Pragma (String, Maybe [TyVarBndrUnit], [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] Source #

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

_UnboxedTupE :: Prism' Exp [Maybe Exp] Source #

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

_DoE :: Prism' Exp (Maybe ModName, [Stmt]) Source #

_DoE :: Prism' Exp (Maybe ModName, [Stmt]) -- template-haskell-2.17+
_DoE :: Prism' Exp [Stmt]                  -- Earlier versions

_MDoE :: Prism' Exp (Maybe ModName, [Stmt]) Source #

_MDoE :: Prism' Exp (Maybe ModName, [Stmt]) -- template-haskell-2.17+
_MDoE :: Prism' Exp [Stmt]                  -- Earlier versions

Body Prisms

Guard Prisms

Stmt Prisms

Range Prisms

Lit Prisms

Pat Prisms

_ConP :: Prism' Pat (Name, [Type], [Pat]) Source #

_ConP :: Prism' Pat (Name, [Type], [Pat]) -- template-haskell-2.18+
_ConP :: Prism' Pat (Name,         [Pat]) -- Earlier versions

Type Prisms

Specificity Prisms

BndrVis Prisms

TyVarBndr Prisms

_PlainTV :: forall flag p f. (Choice p, Applicative f) => p (Name, flag) (f (Name, flag)) -> p (TyVarBndr flag) (f (TyVarBndr flag)) Source #

_PlainTV :: Prism' (TyVarBndr flag) (Name, flag) -- template-haskell-2.17+
_PlainTV :: Prism'  TyVarBndr        Name        -- Earlier versions

_KindedTV :: forall flag p f. (Choice p, Applicative f) => p (Name, flag, Kind) (f (Name, flag, Kind)) -> p (TyVarBndr flag) (f (TyVarBndr flag)) Source #

_KindedTV :: Prism' (TyVarBndr flag) (Name, flag, Kind) -- template-haskell-2.17+
_KindedTV :: Prism'  TyVarBndr       (Name,       Kind) -- Earlier versions

FamilyResultSig Prisms

TyLit Prisms

Role Prisms

DerivStrategy Prisms