Copyright | (c) 2020 Michael Szvetits (c) 2023 Yamada Ryo |
---|---|
License | MPL-2.0 (see the file LICENSE) |
Maintainer | ymdfield@outlook.jp |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Synopsis
- generateEffectDataByEffInfo :: EffectOrder -> Name -> EffectInfo -> Q (DataInfo (), Dec)
- interfaceToCon :: EffectInfo -> Type -> MethodInterface -> Q (EffectOrder, Con)
- analyzeMethodInterface :: TyVarBndr () -> Type -> Q (EffectOrder, [Type], Type, Cxt)
- renameMethodToCon :: Name -> Name
- data EffectOrder
- isHigherOrder :: EffectOrder -> Bool
- defaultEffectDataNamer :: EffectOrder -> String -> String
- effectOrderSymbol :: EffectOrder -> (Char, Char)
- generateLiftInsPatternSynonyms :: Name -> EffectInfo -> Q [Dec]
- generateLiftInsTypeSynonym :: EffectInfo -> Name -> Q Dec
- renameI2S :: String -> Q String
- dropEndI :: String -> Q String
- liftInsType :: Name -> [Name] -> Q Type
- applyEffPVs :: Name -> [Name] -> Q Type
- data EffectInfo = EffectInfo {
- effCxts :: [Type]
- effName :: Name
- effParamVars :: [TyVarBndr ()]
- effMonad :: TyVarBndr ()
- effMethods :: [MethodInterface]
- effParamVar :: (Name, Maybe Kind) -> TyVarBndr ()
- data MethodInterface = MethodInterface {
- methodName :: Name
- methodOrder :: EffectOrder
- methodParamTypes :: [Type]
- methodReturnType :: Type
- methodCxt :: Cxt
- reifyEffectInfo :: Name -> Q EffectInfo
- effectType :: EffectInfo -> Q Type
- partitionSuperEffects :: EffectInfo -> (Cxt, [Type])
- superEffects :: EffectInfo -> [Type]
- superEffectsWithoutBase :: EffectInfo -> [Type]
- effectParamCxt :: EffectInfo -> Cxt
- pureNamer :: (String -> String) -> Name -> Q Name
- unkindType :: Type -> Type
- unkindTyVar :: TyVarBndr a -> TyVarBndr a
- tyVarType :: TyVarBndr a -> Q Type
- tyVarKind :: TyVarBndr a -> Q Type
- paramCount :: Type -> Int
- occurs :: Name -> Type -> Bool
Documentation
generateEffectDataByEffInfo Source #
:: EffectOrder | An effect order of an effect data type to generate. |
-> Name | A name of an effect data type to generate. |
-> EffectInfo | |
-> Q (DataInfo (), Dec) |
Generate instruction and signature data types from an effect class, from EffectInfo
.
interfaceToCon :: EffectInfo -> Type -> MethodInterface -> Q (EffectOrder, Con) Source #
Convert an effect method interface to a constructor of the effect data type.
analyzeMethodInterface :: TyVarBndr () -> Type -> Q (EffectOrder, [Type], Type, Cxt) Source #
Decompose an effect method interface type to get the effect order, the list of argument types, and the return type.
renameMethodToCon :: Name -> Name Source #
Convert a lower-camel-cased method name to an upper-camel-cased constructor name.
data EffectOrder Source #
An order of effect.
Instances
Show EffectOrder Source # | |
Defined in Data.Effect.Class.TH.Internal showsPrec :: Int -> EffectOrder -> ShowS # show :: EffectOrder -> String # showList :: [EffectOrder] -> ShowS # | |
Eq EffectOrder Source # | |
Defined in Data.Effect.Class.TH.Internal (==) :: EffectOrder -> EffectOrder -> Bool # (/=) :: EffectOrder -> EffectOrder -> Bool # | |
Ord EffectOrder Source # | |
Defined in Data.Effect.Class.TH.Internal compare :: EffectOrder -> EffectOrder -> Ordering # (<) :: EffectOrder -> EffectOrder -> Bool # (<=) :: EffectOrder -> EffectOrder -> Bool # (>) :: EffectOrder -> EffectOrder -> Bool # (>=) :: EffectOrder -> EffectOrder -> Bool # max :: EffectOrder -> EffectOrder -> EffectOrder # min :: EffectOrder -> EffectOrder -> EffectOrder # |
isHigherOrder :: EffectOrder -> Bool Source #
Is the order of effect higher-order?
defaultEffectDataNamer :: EffectOrder -> String -> String Source #
The default naming convention of effect data types.
Add an I
or S
symbol indicating the order of the effect to the end of the effect class name.
If the name of the effect class ends in F
or H
, depending on its order, replace F
or H
with
I
or S
.
effectOrderSymbol :: EffectOrder -> (Char, Char) Source #
Symbol letters representing the order of the effect.
Generating Synonyms about LiftIns
generateLiftInsPatternSynonyms :: Name -> EffectInfo -> Q [Dec] Source #
Generate the pattern synonyms for instruction constructors:
pattern BazS ... = LiftIns (Baz ...)
generateLiftInsTypeSynonym :: EffectInfo -> Name -> Q Dec Source #
Generate the type synonym for an instruction datatype:
type (FoobarS ...) = LiftIns (FoobarI ...)
Reification of Effect Class
data EffectInfo Source #
Information about effect type classes.
EffectInfo | |
|
data MethodInterface Source #
MethodInterface | |
|
reifyEffectInfo :: Name -> Q EffectInfo Source #
Given a type class name, extracts infos about an effect.
effectType :: EffectInfo -> Q Type Source #
Constructs the type of an effect, i.e. the type class without its monad parameter.
partitionSuperEffects :: EffectInfo -> (Cxt, [Type]) Source #
superEffects :: EffectInfo -> [Type] Source #
Extracts the super classes of an effect which have the kind of effects. As an example, for the following effect ...
class (State s m, Monad m) => MyEffect s m where ...
... this would pure [State s, Monad].
superEffectsWithoutBase :: EffectInfo -> [Type] Source #
Like superEffects, but ignores super classes from base (i.e., Applicative, Functor, Monad, MonadIO).
effectParamCxt :: EffectInfo -> Cxt Source #
Utility functions
pureNamer :: (String -> String) -> Name -> Q Name Source #
Construct a namer from a conversion function of string.
unkindType :: Type -> Type Source #
Throws away all kind information from a type.
unkindTyVar :: TyVarBndr a -> TyVarBndr a Source #
Throws away the kind information of a type variable.
paramCount :: Type -> Int Source #
Counts the parameters of a type.