classy-effects-th-0.1.0.0: Automatic compliance with the classy-effects protocols
Copyright(c) 2020 Michael Szvetits
(c) 2023 Yamada Ryo
LicenseMPL-2.0 (see the file LICENSE)
Maintainerymdfield@outlook.jp
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageGHC2021

Data.Effect.Class.TH.Internal

Description

 
Synopsis

Documentation

generateEffectDataByEffInfo Source #

Arguments

:: 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.

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.

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.

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).

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.

tyVarType :: TyVarBndr a -> Q Type Source #

Converts a type variable to a type.

paramCount :: Type -> Int Source #

Counts the parameters of a type.

occurs :: Name -> Type -> Bool Source #

Checks if a name m appears somewhere in a type.