Lens.Micro.TH.Internal

microlens-th-0.4.3.16: Automatic generation of record lenses for microlens

Copyright | (C) 2013-2016 Eric Mertens Edward Kmett; 2018 Monadfix
License | BSD-style (see the file LICENSE)
Safe Haskell | Safe
Language | Haskell2010

Lens.Micro.TH.Internal

Contents

- Name utilities
- Type variable utilities
- Miscellaneous utilities
- Lens functions

Description

Functions used by Lens.Micro.TH. This is an internal module and it may go away or change at any time; do not depend on it.

Synopsis

- class HasName t where
  - name :: Lens' t Name
- newNames :: String -> Int -> Q [Name]
- class HasTypeVars t where
  - typeVarsEx :: Set Name -> Traversal' t Name
- typeVars :: HasTypeVars t => Traversal' t Name
- substTypeVars :: HasTypeVars t => Map Name Name -> t -> t
- datatypeTypeKinded :: DatatypeInfo -> Type
- inlinePragma :: Name -> [DecQ]
- conAppsT :: Name -> [Type] -> Type
- quantifyType :: Cxt -> Type -> Type
- quantifyType' :: Set Name -> Cxt -> Type -> Type
- tvbToType :: TyVarBndr_ flag -> Type
- unSigT :: Type -> Type
- elemOf :: Eq a => Getting (Endo [a]) s a -> a -> s -> Bool
- lengthOf :: Getting (Endo [a]) s a -> s -> Int
- setOf :: Ord a => Getting (Endo [a]) s a -> s -> Set a
- _ForallT :: Traversal' Type ([TyVarBndrSpec], Cxt, Type)

# Name utilities

class HasName t where #

Has a `Name`

Methods

name :: Lens' t Name #

Extract (or modify) the `Name` of something

#### Instances

Instances details

HasName Con # | On `template-haskell-2.11.0.0` or later, if a `GadtC` or `RecGadtC` has multiple `Name`s, the leftmost `Name` will be chosen.
Instance details Defined in Lens.Micro.TH.Internal Methods name :: Lens' Con Name #
HasName Name # |
Instance details Defined in Lens.Micro.TH.Internal Methods name :: Lens' Name Name #
HasName (TyVarBndr_ flag) # |
Instance details Defined in Lens.Micro.TH.Internal Methods name :: Lens' (TyVarBndr_ flag) Name #

newNames #

Arguments

:: String | base name
-> Int | count
-> Q [Name] |

Generate many new names from a given base name.

# Type variable utilities

class HasTypeVars t where #

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

Methods

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

#### Instances

Instances details

HasTypeVars Con # |
Instance details Defined in Lens.Micro.TH.Internal Methods typeVarsEx :: Set Name -> Traversal' Con Name #
HasTypeVars Name # |
Instance details Defined in Lens.Micro.TH.Internal Methods typeVarsEx :: Set Name -> Traversal' Name Name #
HasTypeVars Type # |
Instance details Defined in Lens.Micro.TH.Internal Methods typeVarsEx :: Set Name -> Traversal' Type Name #
HasTypeVars (TyVarBndr_ flag) # |
Instance details Defined in Lens.Micro.TH.Internal Methods typeVarsEx :: Set Name -> Traversal' (TyVarBndr_ flag) Name #
HasTypeVars t => HasTypeVars (Maybe t) # |
Instance details Defined in Lens.Micro.TH.Internal Methods typeVarsEx :: Set Name -> Traversal' (Maybe t) Name #
HasTypeVars t => HasTypeVars [t] # |
Instance details Defined in Lens.Micro.TH.Internal Methods typeVarsEx :: Set Name -> Traversal' [t] Name #

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

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

# Miscellaneous utilities

datatypeTypeKinded :: DatatypeInfo -> Type #

inlinePragma :: Name -> [DecQ] #

Generate an INLINE pragma.

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

Apply arguments to a type constructor.

quantifyType :: Cxt -> Type -> Type #

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

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

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

tvbToType :: TyVarBndr_ flag -> Type #

Convert a `TyVarBndr` into its corresponding `Type`.

unSigT :: Type -> Type #

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

# Lens functions

elemOf :: Eq a => Getting (Endo [a]) s a -> a -> s -> Bool #

lengthOf :: Getting (Endo [a]) s a -> s -> Int #

setOf :: Ord a => Getting (Endo [a]) s a -> s -> Set a #

_ForallT :: Traversal' Type ([TyVarBndrSpec], Cxt, Type) #