lens
Copyright(C) 2013-2016 Edward Kmett and Eric Mertens
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe
LanguageHaskell2010

Control.Lens.Internal.TH

Description

 
Synopsis

Documentation

unSigT :: Type -> Type Source #

Peel off a kind signature from a Type (if it has one).

quantifyType :: Cxt -> Type -> Type Source #

Template Haskell wants type variables declared in a forall, so we find all free type variables in a given type and declare them.

appsT :: TypeQ -> [TypeQ] -> TypeQ Source #

Apply arguments to a type constructor

haskellKeywords :: Set String Source #

Haskell's reserved identifiers, which cannot be used as names of functions or class methods.

This mirrors the check GHC applies to spliced declarations (okVarOcc/reservedIds in GHC.Utils.Lexeme from ghc-boot, on which we do not wish to depend). GHC 9.10 and later treat forall as an unconditional keyword, so it is included when building with those GHCs.

ghcExtensionKeywords :: Set String Source #

Identifiers reserved by GHC language extensions.

explicitForAllKeywords :: Set String Source #

Identifiers that explicit-forall extensions reserve: forall.

recursiveDoKeywords :: Set String Source #

Identifiers that the RecursiveDo extension reserves: mdo and rec.

arrowsKeywords :: Set String Source #

Identifiers that the Arrows extension reserves: proc and rec.

patternSynonymsKeywords :: Set String Source #

Identifiers that the PatternSynonyms extension reserves: pattern.

transformListCompKeywords :: Set String Source #

Identifiers that the TransformListComp extension reserves: by and using.

staticPointersKeywords :: Set String Source #

Identifiers that the StaticPointers extension reserves: static.

roleAnnotationsKeywords :: Set String Source #

Identifiers that the RoleAnnotations extension reserves: role.

This is provided for callers who want a conservative list of extension keywords. activeKeywords deliberately does not reject role, since it is still valid as a generated function or class method name.

appsE1 :: ExpQ -> [ExpQ] -> ExpQ Source #

Apply arguments to a function

toTupleT :: [TypeQ] -> TypeQ Source #

Construct a tuple type given a list of types.

toTupleE :: [ExpQ] -> ExpQ Source #

Construct a tuple value given a list of expressions.

toTupleP :: [PatQ] -> PatQ Source #

Construct a tuple pattern given a list of patterns.

conAppsT :: Name -> [Type] -> Type Source #

Apply arguments to a type constructor.

newNames Source #

Arguments

:: String

base name

-> Int

count

-> Q [Name] 

Generate many new names from a given base name.

unfoldType :: Type -> (Type, [Type]) Source #

Decompose an applied type into its individual components. For example, this:

Either Int Char

would be unfolded to this:

(ConT ''Either, [ConT ''Int, ConT ''Char])

This function ignores explicit parentheses and visible kind applications.

dropSigsIfNonDataFam :: DatatypeInfo -> [Type] -> [Type] Source #

In an effort to prevent users from having to enable KindSignatures every time that they use lens' TH functionality, we strip off reified kind annotations from when:

  1. The kind of a type does not contain any kind variables. If it *does* contain kind variables, we want to preserve them so that we can generate type signatures that preserve the dependency order of kind and type variables. (The data types in test/T917.hs contain examples where this is important.) This will require enabling PolyKinds, but since PolyKinds implies KindSignatures, we can at least accomplish two things at once.
  2. The data type is not an instance of a data family. We make an exception for data family instances, since the presence or absence of a kind annotation can be the difference between typechecking or not. (See T917DataFam in tests/T917.hs for an example.) Moreover, the TypeFamilies extension implies KindSignatures.

quantifyType' :: Set Name -> Cxt -> Type -> Type Source #

This function works like quantifyType except that it takes a list of variables to exclude from quantification.

tvbToType :: TyVarBndr_ flag -> Type Source #

Convert a TyVarBndr into its corresponding Type.

activeKeywords :: Q (Set String) Source #

Haskell keywords plus the identifiers reserved by enabled extensions that would make generated functions or class methods fail to parse.

avoidName :: Set String -> Name -> Name Source #

Append an underscore to a name that belongs to the given set of reserved identifiers; leave all other names untouched.

phantom2 :: (Functor f, Contravariant f) => f a -> f b Source #

inlinePragma :: Name -> [DecQ] Source #

type TyVarBndrVis = TyVarBndr_ BndrVis #

A TyVarBndr with a BndrVis flag. This is used for TyVarBndrs in type-level declarations (e.g., the binders in data D @k (a :: k)).