Copyright | (C) 2012-2016 Edward Kmett |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | experimental |
Portability | TemplateHaskell |
Safe Haskell | Safe |
Language | Haskell98 |
- Traversals
- Lenses
- Prisms
- Info Prisms
- Dec Prisms
- PatSynDir Prisms
- PatSynArgs Prisms
- Con Prisms
- Overlap Prisms
- SourceUnpackedness Prisms
- SourceStrictness Prisms
- DecidedStrictness Prisms
- Foreign Prisms
- Callconv Prisms
- Safety Prisms
- Pragma Prisms
- Inline Prisms
- RuleMatch Prisms
- Phases Prisms
- RuleBndr Prisms
- AnnTarget Prisms
- FunDep Prisms TODO make a lens
- FamFlavour Prisms
- FixityDirection Prisms
- Exp Prisms
- Body Prisms
- Guard Prisms
- Stmt Prisms
- Range Prisms
- Lit Prisms
- Pat Prisms
- Type Prisms
- TyVarBndr Prisms
- FamilyResultSig Prisms
- TyLit Prisms
- Role Prisms
- DerivStrategy Prisms
Lenses, Prisms, and Traversals for working with Template Haskell
Synopsis
- class HasName t where
- class HasTypes t where
- class HasTypeVars t where
- class SubstType t where
- typeVars :: HasTypeVars t => Traversal' t Name
- substTypeVars :: HasTypeVars t => Map Name Name -> t -> t
- conFields :: Traversal' Con BangType
- conNamedFields :: Traversal' Con VarBangType
- locFileName :: Lens' Loc String
- locPackage :: Lens' Loc String
- locModule :: Lens' Loc String
- locStart :: Lens' Loc CharPos
- locEnd :: Lens' Loc CharPos
- funDepInputs :: Lens' FunDep [Name]
- funDepOutputs :: Lens' FunDep [Name]
- matchPattern :: Lens' Match Pat
- matchBody :: Lens' Match Body
- matchDeclarations :: Lens' Match [Dec]
- fixityPrecedence :: Lens' Fixity Int
- fixityDirection :: Lens' Fixity FixityDirection
- clausePattern :: Lens' Clause [Pat]
- clauseBody :: Lens' Clause Body
- clauseDecs :: Lens' Clause [Dec]
- fieldExpName :: Lens' FieldExp Name
- fieldExpExpression :: Lens' FieldExp Exp
- fieldPatName :: Lens' FieldPat Name
- fieldPatPattern :: Lens' FieldPat Pat
- tySynEqnPatterns :: Lens' TySynEqn [Type]
- tySynEqnResult :: Lens' TySynEqn Type
- injectivityAnnOutput :: Lens' InjectivityAnn Name
- injectivityAnnInputs :: Lens' InjectivityAnn [Name]
- typeFamilyHeadName :: Lens' TypeFamilyHead Name
- typeFamilyHeadTyVarBndrs :: Lens' TypeFamilyHead [TyVarBndr]
- typeFamilyHeadResultSig :: Lens' TypeFamilyHead FamilyResultSig
- typeFamilyHeadInjectivityAnn :: Lens' TypeFamilyHead (Maybe InjectivityAnn)
- bangSourceUnpackedness :: Lens' Bang SourceUnpackedness
- bangSourceStrictness :: Lens' Bang SourceStrictness
- derivClauseStrategy :: Lens' DerivClause (Maybe DerivStrategy)
- derivClauseCxt :: Lens' DerivClause Cxt
- _ClassI :: Prism' Info (Dec, [InstanceDec])
- _ClassOpI :: Prism' Info (Name, Type, ParentName)
- _TyConI :: Prism' Info Dec
- _FamilyI :: Prism' Info (Dec, [InstanceDec])
- _PrimTyConI :: Prism' Info (Name, Arity, Unlifted)
- _DataConI :: Prism' Info (Name, Type, ParentName)
- _VarI :: Prism' Info (Name, Type, Maybe Dec)
- _TyVarI :: Prism' Info (Name, Type)
- _PatSynI :: Prism' Info (Name, PatSynType)
- _FunD :: Prism' Dec (Name, [Clause])
- _ValD :: Prism' Dec (Pat, Body, [Dec])
- _DataD :: DataPrism' [TyVarBndr] [Con]
- _NewtypeD :: DataPrism' [TyVarBndr] Con
- _TySynD :: Prism' Dec (Name, [TyVarBndr], Type)
- _ClassD :: Prism' Dec (Cxt, Name, [TyVarBndr], [FunDep], [Dec])
- _InstanceD :: Prism' Dec (Maybe Overlap, Cxt, Type, [Dec])
- _SigD :: Prism' Dec (Name, Type)
- _ForeignD :: Prism' Dec Foreign
- _InfixD :: Prism' Dec (Fixity, Name)
- _PragmaD :: Prism' Dec Pragma
- _DataInstD :: DataPrism' [Type] [Con]
- _NewtypeInstD :: DataPrism' [Type] Con
- _TySynInstD :: Prism' Dec (Name, TySynEqn)
- _ClosedTypeFamilyD :: Prism' Dec (TypeFamilyHead, [TySynEqn])
- _RoleAnnotD :: Prism' Dec (Name, [Role])
- _StandaloneDerivD :: Prism' Dec (Maybe DerivStrategy, Cxt, Type)
- _DefaultSigD :: Prism' Dec (Name, Type)
- _DataFamilyD :: Prism' Dec (Name, [TyVarBndr], Maybe Kind)
- _OpenTypeFamilyD :: Prism' Dec TypeFamilyHead
- _PatSynD :: Prism' Dec (Name, PatSynArgs, PatSynDir, Pat)
- _PatSynSigD :: Prism' Dec (Name, PatSynType)
- _Unidir :: Prism' PatSynDir ()
- _ImplBidir :: Prism' PatSynDir ()
- _ExplBidir :: Prism' PatSynDir [Clause]
- _PrefixPatSyn :: Prism' PatSynArgs [Name]
- _InfixPatSyn :: Prism' PatSynArgs (Name, Name)
- _RecordPatSyn :: Prism' PatSynArgs [Name]
- _NormalC :: Prism' Con (Name, [BangType])
- _RecC :: Prism' Con (Name, [VarBangType])
- _InfixC :: Prism' Con (BangType, Name, BangType)
- _ForallC :: Prism' Con ([TyVarBndr], Cxt, Con)
- _GadtC :: Prism' Con ([Name], [BangType], Type)
- _RecGadtC :: Prism' Con ([Name], [VarBangType], Type)
- _Overlappable :: Prism' Overlap ()
- _Overlapping :: Prism' Overlap ()
- _Overlaps :: Prism' Overlap ()
- _Incoherent :: Prism' Overlap ()
- _NoSourceUnpackedness :: Prism' SourceUnpackedness ()
- _SourceNoUnpack :: Prism' SourceUnpackedness ()
- _SourceUnpack :: Prism' SourceUnpackedness ()
- _NoSourceStrictness :: Prism' SourceStrictness ()
- _SourceLazy :: Prism' SourceStrictness ()
- _SourceStrict :: Prism' SourceStrictness ()
- _DecidedLazy :: Prism' DecidedStrictness ()
- _DecidedStrict :: Prism' DecidedStrictness ()
- _DecidedUnpack :: Prism' DecidedStrictness ()
- _ImportF :: Prism' Foreign (Callconv, Safety, String, Name, Type)
- _ExportF :: Prism' Foreign (Callconv, String, Name, Type)
- _CCall :: Prism' Callconv ()
- _StdCall :: Prism' Callconv ()
- _CApi :: Prism' Callconv ()
- _Prim :: Prism' Callconv ()
- _JavaScript :: Prism' Callconv ()
- _Unsafe :: Prism' Safety ()
- _Safe :: Prism' Safety ()
- _Interruptible :: Prism' Safety ()
- _InlineP :: Prism' Pragma (Name, Inline, RuleMatch, Phases)
- _SpecialiseP :: Prism' Pragma (Name, Type, Maybe Inline, Phases)
- _SpecialiseInstP :: Prism' Pragma Type
- _RuleP :: Prism' Pragma (String, [RuleBndr], Exp, Exp, Phases)
- _AnnP :: Prism' Pragma (AnnTarget, Exp)
- _LineP :: Prism' Pragma (Int, String)
- _CompleteP :: Prism' Pragma ([Name], Maybe Name)
- _NoInline :: Prism' Inline ()
- _Inline :: Prism' Inline ()
- _Inlinable :: Prism' Inline ()
- _ConLike :: Prism' RuleMatch ()
- _FunLike :: Prism' RuleMatch ()
- _AllPhases :: Prism' Phases ()
- _FromPhase :: Prism' Phases Int
- _BeforePhase :: Prism' Phases Int
- _RuleVar :: Prism' RuleBndr Name
- _TypedRuleVar :: Prism' RuleBndr (Name, Type)
- _ModuleAnnotation :: Prism' AnnTarget ()
- _TypeAnnotation :: Prism' AnnTarget Name
- _ValueAnnotation :: Prism' AnnTarget Name
- _FunDep :: Iso' FunDep ([Name], [Name])
- _TypeFam :: Prism' FamFlavour ()
- _DataFam :: Prism' FamFlavour ()
- _InfixL :: Prism' FixityDirection ()
- _InfixR :: Prism' FixityDirection ()
- _InfixN :: Prism' FixityDirection ()
- _VarE :: Prism' Exp Name
- _ConE :: Prism' Exp Name
- _LitE :: Prism' Exp Lit
- _AppE :: Prism' Exp (Exp, Exp)
- _AppTypeE :: Prism' Exp (Exp, Type)
- _InfixE :: Prism' Exp (Maybe Exp, Exp, Maybe Exp)
- _UInfixE :: Prism' Exp (Exp, Exp, Exp)
- _ParensE :: Prism' Exp Exp
- _LamE :: Prism' Exp ([Pat], Exp)
- _LamCaseE :: Prism' Exp [Match]
- _TupE :: Prism' Exp [Exp]
- _UnboxedTupE :: Prism' Exp [Exp]
- _UnboxedSumE :: Prism' Exp (Exp, SumAlt, SumArity)
- _CondE :: Prism' Exp (Exp, Exp, Exp)
- _MultiIfE :: Prism' Exp [(Guard, Exp)]
- _LetE :: Prism' Exp ([Dec], Exp)
- _CaseE :: Prism' Exp (Exp, [Match])
- _DoE :: Prism' Exp [Stmt]
- _CompE :: Prism' Exp [Stmt]
- _ArithSeqE :: Prism' Exp Range
- _ListE :: Prism' Exp [Exp]
- _SigE :: Prism' Exp (Exp, Type)
- _RecConE :: Prism' Exp (Name, [FieldExp])
- _RecUpdE :: Prism' Exp (Exp, [FieldExp])
- _StaticE :: Prism' Exp Exp
- _UnboundVarE :: Prism' Exp Name
- _GuardedB :: Prism' Body [(Guard, Exp)]
- _NormalB :: Prism' Body Exp
- _NormalG :: Prism' Guard Exp
- _PatG :: Prism' Guard [Stmt]
- _BindS :: Prism' Stmt (Pat, Exp)
- _LetS :: Prism' Stmt [Dec]
- _NoBindS :: Prism' Stmt Exp
- _ParS :: Prism' Stmt [[Stmt]]
- _FromR :: Prism' Range Exp
- _FromThenR :: Prism' Range (Exp, Exp)
- _FromToR :: Prism' Range (Exp, Exp)
- _FromThenToR :: Prism' Range (Exp, Exp, Exp)
- _CharL :: Prism' Lit Char
- _StringL :: Prism' Lit String
- _IntegerL :: Prism' Lit Integer
- _RationalL :: Prism' Lit Rational
- _IntPrimL :: Prism' Lit Integer
- _WordPrimL :: Prism' Lit Integer
- _FloatPrimL :: Prism' Lit Rational
- _DoublePrimL :: Prism' Lit Rational
- _StringPrimL :: Prism' Lit [Word8]
- _CharPrimL :: Prism' Lit Char
- _LitP :: Prism' Pat Lit
- _VarP :: Prism' Pat Name
- _TupP :: Prism' Pat [Pat]
- _UnboxedTupP :: Prism' Pat [Pat]
- _UnboxedSumP :: Prism' Pat (Pat, SumAlt, SumArity)
- _ConP :: Prism' Pat (Name, [Pat])
- _InfixP :: Prism' Pat (Pat, Name, Pat)
- _UInfixP :: Prism' Pat (Pat, Name, Pat)
- _ParensP :: Prism' Pat Pat
- _TildeP :: Prism' Pat Pat
- _BangP :: Prism' Pat Pat
- _AsP :: Prism' Pat (Name, Pat)
- _WildP :: Prism' Pat ()
- _RecP :: Prism' Pat (Name, [FieldPat])
- _ListP :: Prism' Pat [Pat]
- _SigP :: Prism' Pat (Pat, Type)
- _ViewP :: Prism' Pat (Exp, Pat)
- _ForallT :: Prism' Type ([TyVarBndr], Cxt, Type)
- _AppT :: Prism' Type (Type, Type)
- _SigT :: Prism' Type (Type, Kind)
- _VarT :: Prism' Type Name
- _ConT :: Prism' Type Name
- _PromotedT :: Prism' Type Name
- _TupleT :: Prism' Type Int
- _UnboxedTupleT :: Prism' Type Int
- _UnboxedSumT :: Prism' Type SumArity
- _ArrowT :: Prism' Type ()
- _EqualityT :: Prism' Type ()
- _ListT :: Prism' Type ()
- _PromotedTupleT :: Prism' Type Int
- _PromotedNilT :: Prism' Type ()
- _PromotedConsT :: Prism' Type ()
- _StarT :: Prism' Type ()
- _ConstraintT :: Prism' Type ()
- _LitT :: Prism' Type TyLit
- _InfixT :: Prism' Type (Type, Name, Type)
- _UInfixT :: Prism' Type (Type, Name, Type)
- _ParensT :: Prism' Type Type
- _WildCardT :: Prism' Type ()
- _PlainTV :: Prism' TyVarBndr Name
- _KindedTV :: Prism' TyVarBndr (Name, Kind)
- _NoSig :: Prism' FamilyResultSig ()
- _KindSig :: Prism' FamilyResultSig Kind
- _TyVarSig :: Prism' FamilyResultSig TyVarBndr
- _NumTyLit :: Prism' TyLit Integer
- _StrTyLit :: Prism' TyLit String
- _NominalR :: Prism' Role ()
- _RepresentationalR :: Prism' Role ()
- _PhantomR :: Prism' Role ()
- _InferR :: Prism' Role ()
- _StockStrategy :: Prism' DerivStrategy ()
- _AnyclassStrategy :: Prism' DerivStrategy ()
- _NewtypeStrategy :: Prism' DerivStrategy ()
Traversals
class HasName t where Source #
Has a Name
Instances
HasName Name Source # | |
HasName TyVarBndr Source # | |
HasName InjectivityAnn Source # | |
HasName TypeFamilyHead Source # | |
HasName Foreign Source # | |
HasName RuleBndr Source # | |
HasName Con Source # | On |
class HasTypes t where Source #
Contains some amount of Type
s inside
types :: Traversal' t Type Source #
Traverse all the types
class HasTypeVars t where Source #
Provides for the extraction of free type variables, and alpha renaming.
typeVarsEx :: Set Name -> Traversal' t Name Source #
Instances
HasTypeVars Type Source # | |
typeVarsEx :: Set Name -> Traversal' Type Name Source # | |
HasTypeVars Name Source # | |
typeVarsEx :: Set Name -> Traversal' Name Name Source # | |
HasTypeVars TyVarBndr Source # | |
typeVarsEx :: Set Name -> Traversal' TyVarBndr Name Source # | |
HasTypeVars Con Source # | |
typeVarsEx :: Set Name -> Traversal' Con Name Source # | |
HasTypeVars t => HasTypeVars [t] Source # | |
typeVarsEx :: Set Name -> Traversal' [t] Name Source # | |
HasTypeVars t => HasTypeVars (Maybe t) Source # | |
typeVarsEx :: Set Name -> Traversal' (Maybe t) Name 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
_DataInstD :: DataPrism' [Type] [Con] Source #
_NewtypeInstD :: DataPrism' [Type] Con Source #
_ClosedTypeFamilyD :: Prism' Dec (TypeFamilyHead, [TySynEqn]) Source #
_StandaloneDerivD :: Prism' Dec (Maybe DerivStrategy, Cxt, Type) Source #
_PatSynSigD :: Prism' Dec (Name, PatSynType) Source #
PatSynDir Prisms
_ImplBidir :: Prism' PatSynDir () Source #
PatSynArgs Prisms
_PrefixPatSyn :: Prism' PatSynArgs [Name] Source #
_InfixPatSyn :: Prism' PatSynArgs (Name, Name) Source #
_RecordPatSyn :: Prism' PatSynArgs [Name] Source #
Con Prisms
Overlap Prisms
_Overlappable :: Prism' Overlap () Source #
_Overlapping :: Prism' Overlap () Source #
_Incoherent :: Prism' Overlap () Source #
SourceUnpackedness Prisms
SourceStrictness Prisms
_SourceLazy :: Prism' SourceStrictness () Source #
DecidedStrictness Prisms
Foreign Prisms
Callconv Prisms
_JavaScript :: Prism' Callconv () Source #
Safety Prisms
_Interruptible :: Prism' Safety () Source #
Pragma Prisms
Inline Prisms
_Inlinable :: Prism' Inline () Source #
RuleMatch Prisms
Phases Prisms
_AllPhases :: Prism' Phases () Source #
RuleBndr Prisms
AnnTarget Prisms
_ModuleAnnotation :: Prism' AnnTarget () Source #
FunDep Prisms TODO make a lens
FamFlavour Prisms
_TypeFam :: Prism' FamFlavour () Source #
_DataFam :: Prism' FamFlavour () Source #
FixityDirection Prisms
_InfixL :: Prism' FixityDirection () Source #
_InfixR :: Prism' FixityDirection () Source #
_InfixN :: Prism' FixityDirection () Source #
Exp Prisms
Body Prisms
Guard Prisms
Stmt Prisms
Range Prisms
Lit Prisms
Pat Prisms
Type Prisms
_EqualityT :: Prism' Type () Source #
_PromotedNilT :: Prism' Type () Source #
_PromotedConsT :: Prism' Type () Source #
_ConstraintT :: Prism' Type () Source #
_WildCardT :: Prism' Type () Source #
TyVarBndr Prisms
FamilyResultSig Prisms
_NoSig :: Prism' FamilyResultSig () Source #
TyLit Prisms
Role Prisms
_RepresentationalR :: Prism' Role () Source #
DerivStrategy Prisms
_StockStrategy :: Prism' DerivStrategy () Source #