Safe Haskell | None |
---|---|
Language | Haskell98 |
Data.Params
Contents
- data Config a
- mkParams :: Name -> Q [Dec]
- with1Param :: forall p m. ParamIndex p => TypeLens Base p -> ParamType p -> (ApplyConstraint p m => m) -> m
- with1ParamAutomatic :: forall p tr ta. (ParamIndex p, RunTimeToAutomatic p tr ta) => TypeLens Base p -> ParamType p -> (ApplyConstraint p tr => tr) -> ta
- apWith1Param :: forall p m n. ParamIndex p => TypeLens Base p -> ParamType p -> (ApplyConstraint p m => m -> n) -> (ApplyConstraint p m => m) -> n
- apWith2Param :: forall p1 p2 m n. (ParamIndex p1, ParamIndex p2) => TypeLens Base p1 -> ParamType p1 -> TypeLens Base p2 -> ParamType p2 -> ((ApplyConstraint p1 m, ApplyConstraint p2 m) => m -> n) -> ((ApplyConstraint p1 m, ApplyConstraint p2 m) => m) -> n
- apWith3Param :: forall p1 p2 p3 m n. (ParamIndex p1, ParamIndex p2, ParamIndex p3) => TypeLens Base p1 -> ParamType p1 -> TypeLens Base p2 -> ParamType p2 -> TypeLens Base p3 -> ParamType p3 -> ((ApplyConstraint p1 m, ApplyConstraint p2 m, ApplyConstraint p3 m) => m -> n) -> ((ApplyConstraint p1 m, ApplyConstraint p2 m, ApplyConstraint p3 m) => m) -> n
- apWith1Param' :: m -> ParamIndex p => TypeLens Base p -> ParamType p -> (ApplyConstraint p m => m -> n) -> (ApplyConstraint p m => m) -> n
- apWith2Param' :: m -> (ParamIndex p1, ParamIndex p2) => TypeLens Base p1 -> ParamType p1 -> TypeLens Base p2 -> ParamType p2 -> ((ApplyConstraint p1 m, ApplyConstraint p2 m) => m -> n) -> ((ApplyConstraint p1 m, ApplyConstraint p2 m) => m) -> n
- apWith3Param' :: m -> (ParamIndex p1, ParamIndex p2, ParamIndex p3) => TypeLens Base p1 -> ParamType p1 -> TypeLens Base p2 -> ParamType p2 -> TypeLens Base p3 -> ParamType p3 -> ((ApplyConstraint p1 m, ApplyConstraint p2 m, ApplyConstraint p3 m) => m -> n) -> ((ApplyConstraint p1 m, ApplyConstraint p2 m, ApplyConstraint p3 m) => m) -> n
- mkWith1Param :: proxy m -> ParamIndex p => TypeLens Base p -> ParamType p -> (ApplyConstraint p m => m) -> m
- mkApWith1Param :: proxy m -> proxy n -> ParamIndex p => TypeLens Base p -> ParamType p -> (ApplyConstraint p m => m -> n) -> (ApplyConstraint p m => m) -> n
- mkApWith2Param :: proxy m -> proxy n -> (ParamIndex p1, ParamIndex p2) => TypeLens Base p1 -> ParamType p1 -> TypeLens Base p2 -> ParamType p2 -> ((ApplyConstraint p1 m, ApplyConstraint p2 m) => m -> n) -> ((ApplyConstraint p1 m, ApplyConstraint p2 m) => m) -> n
- mkApWith3Param :: proxy m -> proxy n -> (ParamIndex p1, ParamIndex p2, ParamIndex p3) => TypeLens Base p1 -> ParamType p1 -> TypeLens Base p2 -> ParamType p2 -> TypeLens Base p3 -> ParamType p3 -> ((ApplyConstraint p1 m, ApplyConstraint p2 m, ApplyConstraint p3 m) => m -> n) -> ((ApplyConstraint p1 m, ApplyConstraint p2 m, ApplyConstraint p3 m) => m) -> n
- class HasDictionary p where
- class ViewParam p t where
- type ParamIndex p = (ReifiableConstraint (ApplyConstraint_GetConstraint p), HasDictionary p)
- class RunTimeToAutomatic p tr ta | p tr -> ta, p ta -> tr where
- runTimeToAutomatic :: TypeLens Base p -> ParamType p -> (ApplyConstraint p tr => tr) -> ta
- mkPseudoPrimInfoFromRuntime :: TypeLens Base p -> ParamType p -> PseudoPrimInfo tr -> PseudoPrimInfo ta
- class StaticToAutomatic p ts ta | p ts -> ta where
- staticToAutomatic :: TypeLens Base p -> ts -> ta
- mkPseudoPrimInfoFromStatic :: TypeLens Base p -> PseudoPrimInfo ts -> PseudoPrimInfo ta
- type ApplyConstraint p m = ApplyConstraint_GetConstraint p (ApplyConstraint_GetType p m)
- data TypeLens a b = TypeLens
- type family GetParam p t :: k3
- type family SetParam p a t :: *
- type family SetParam' p a t :: *
- type family Objective lens :: * -> Constraint
- type family RemoveObjective lens :: * -> Constraint
- class Base a
- _base :: TypeLens Base Base
- zoom :: TypeLens a p -> TypeLens a (Zoom p)
- objective :: TypeLens q p -> TypeLens q (Objective p)
- removeObjective :: TypeLens p q -> TypeLens p (RemoveObjective q)
- type family Zoom p :: k2
- type family EyePiece p :: k2
- type family ApplyConstraint_GetType p t :: *
- type family ApplyConstraint_GetConstraint p :: * -> Constraint
- coerceParamDict :: (ParamType p -> ParamDict p) -> ParamType p -> ParamDict (a p)
- mkRuleFrac :: Rational -> Q [Dec]
- intparam :: forall n. KnownNat n => Proxy (n :: Nat) -> Int
- floatparam :: forall n. KnownFrac n => Proxy (n :: Frac) -> Float
- data Float :: * = F# Float#
- mkParamClass_Star :: String -> Q [Dec]
- mkParamClass_Config :: String -> Type -> Q [Dec]
- mkTypeLens_Star :: String -> Q [Dec]
- mkTypeLens_Config :: String -> Q [Dec]
- mkHasDictionary_Star :: String -> Q [Dec]
- mkHasDictionary_Config :: String -> Type -> Q [Dec]
- mkViewParam_Star :: String -> Name -> Q [Dec]
- mkViewParam_Config :: String -> Name -> Q [Dec]
- mkApplyConstraint_Star :: String -> Name -> Q [Dec]
- mkApplyConstraint_Config :: String -> Name -> Q [Dec]
- class Param_Dummy t
- mkParamInstance :: String -> Type -> Name -> Q [Dec]
- mkReifiableConstraint :: String -> Q [Dec]
- mkGettersSetters :: Name -> Q [Dec]
- class ReifiableConstraint p where
- data Def p a :: *
- reifiedIns :: Reifies s (Def p a) :- p (ConstraintLift p a s)
- newtype ConstraintLift p a s = ConstraintLift {
- lower :: a
- module GHC.TypeLits
- module Data.Params.Frac
- module Data.Reflection
- module Data.Proxy
- module Data.Constraint
- module Data.Constraint.Unsafe
Basic
(Kind) Specifies that the type parameter can be known either statically or dynamically.
mkParams :: Name -> Q [Dec] Source
Constructs all the needed type classes and instances in order to use typeparams in a simple manner. Example usage:
data NearestNeighbor (k :: Param Nat) (maxdist :: Param Float) elem = ... mkParams ''NearestNeighbor
with1Param :: forall p m. ParamIndex p => TypeLens Base p -> ParamType p -> (ApplyConstraint p m => m) -> m Source
with1ParamAutomatic :: forall p tr ta. (ParamIndex p, RunTimeToAutomatic p tr ta) => TypeLens Base p -> ParamType p -> (ApplyConstraint p tr => tr) -> ta Source
apWith1Param :: forall p m n. ParamIndex p => TypeLens Base p -> ParamType p -> (ApplyConstraint p m => m -> n) -> (ApplyConstraint p m => m) -> n Source
apWith2Param :: forall p1 p2 m n. (ParamIndex p1, ParamIndex p2) => TypeLens Base p1 -> ParamType p1 -> TypeLens Base p2 -> ParamType p2 -> ((ApplyConstraint p1 m, ApplyConstraint p2 m) => m -> n) -> ((ApplyConstraint p1 m, ApplyConstraint p2 m) => m) -> n Source
apWith3Param :: forall p1 p2 p3 m n. (ParamIndex p1, ParamIndex p2, ParamIndex p3) => TypeLens Base p1 -> ParamType p1 -> TypeLens Base p2 -> ParamType p2 -> TypeLens Base p3 -> ParamType p3 -> ((ApplyConstraint p1 m, ApplyConstraint p2 m, ApplyConstraint p3 m) => m -> n) -> ((ApplyConstraint p1 m, ApplyConstraint p2 m, ApplyConstraint p3 m) => m) -> n Source
apWith1Param' :: m -> ParamIndex p => TypeLens Base p -> ParamType p -> (ApplyConstraint p m => m -> n) -> (ApplyConstraint p m => m) -> n Source
apWith2Param' :: m -> (ParamIndex p1, ParamIndex p2) => TypeLens Base p1 -> ParamType p1 -> TypeLens Base p2 -> ParamType p2 -> ((ApplyConstraint p1 m, ApplyConstraint p2 m) => m -> n) -> ((ApplyConstraint p1 m, ApplyConstraint p2 m) => m) -> n Source
apWith3Param' :: m -> (ParamIndex p1, ParamIndex p2, ParamIndex p3) => TypeLens Base p1 -> ParamType p1 -> TypeLens Base p2 -> ParamType p2 -> TypeLens Base p3 -> ParamType p3 -> ((ApplyConstraint p1 m, ApplyConstraint p2 m, ApplyConstraint p3 m) => m -> n) -> ((ApplyConstraint p1 m, ApplyConstraint p2 m, ApplyConstraint p3 m) => m) -> n Source
mkWith1Param :: proxy m -> ParamIndex p => TypeLens Base p -> ParamType p -> (ApplyConstraint p m => m) -> m Source
mkApWith1Param :: proxy m -> proxy n -> ParamIndex p => TypeLens Base p -> ParamType p -> (ApplyConstraint p m => m -> n) -> (ApplyConstraint p m => m) -> n Source
mkApWith2Param :: proxy m -> proxy n -> (ParamIndex p1, ParamIndex p2) => TypeLens Base p1 -> ParamType p1 -> TypeLens Base p2 -> ParamType p2 -> ((ApplyConstraint p1 m, ApplyConstraint p2 m) => m -> n) -> ((ApplyConstraint p1 m, ApplyConstraint p2 m) => m) -> n Source
mkApWith3Param :: proxy m -> proxy n -> (ParamIndex p1, ParamIndex p2, ParamIndex p3) => TypeLens Base p1 -> ParamType p1 -> TypeLens Base p2 -> ParamType p2 -> TypeLens Base p3 -> ParamType p3 -> ((ApplyConstraint p1 m, ApplyConstraint p2 m, ApplyConstraint p3 m) => m -> n) -> ((ApplyConstraint p1 m, ApplyConstraint p2 m, ApplyConstraint p3 m) => m) -> n Source
Classes
class HasDictionary p where Source
Methods
typeLens2dictConstructor :: TypeLens base p -> ParamType p -> ParamDict p Source
Instances
HasDictionary Param_len | |
HasDictionary _p => HasDictionary (Param_b _p) | |
HasDictionary _p => HasDictionary (Param_a _p) | |
HasDictionary _p => HasDictionary (Param_elem _p) |
type ParamIndex p = (ReifiableConstraint (ApplyConstraint_GetConstraint p), HasDictionary p) Source
class RunTimeToAutomatic p tr ta | p tr -> ta, p ta -> tr where Source
Methods
runTimeToAutomatic :: TypeLens Base p -> ParamType p -> (ApplyConstraint p tr => tr) -> ta Source
mkPseudoPrimInfoFromRuntime :: TypeLens Base p -> ParamType p -> PseudoPrimInfo tr -> PseudoPrimInfo ta Source
Instances
PseudoPrim elem => RunTimeToAutomatic Param_len (Vector (RunTime Nat) elem) (Vector (Automatic Nat) elem) | |
(RunTimeToAutomatic p elem elem', HasDictionary p, ReifiableConstraint (ApplyConstraint_GetConstraint (* -> Constraint) p)) => RunTimeToAutomatic (Param_elem p) (Vector (Automatic Nat) elem) (Vector (Automatic Nat) elem') | |
(RunTimeToAutomatic p elem elem', HasDictionary p, ReifiableConstraint (ApplyConstraint_GetConstraint (* -> Constraint) p)) => RunTimeToAutomatic (Param_elem p) (Vector (RunTime Nat) elem) (Vector (RunTime Nat) elem') | |
(RunTimeToAutomatic p elem elem', HasDictionary p, ReifiableConstraint (ApplyConstraint_GetConstraint (* -> Constraint) p)) => RunTimeToAutomatic (Param_elem p) (Vector (Static Nat len) elem) (Vector (Static Nat len) elem') |
class StaticToAutomatic p ts ta | p ts -> ta where Source
Methods
staticToAutomatic :: TypeLens Base p -> ts -> ta Source
mkPseudoPrimInfoFromStatic :: TypeLens Base p -> PseudoPrimInfo ts -> PseudoPrimInfo ta Source
Instances
(KnownNat len, PseudoPrim elem) => StaticToAutomatic Param_len (Vector (Static Nat len) elem) (Vector (Automatic Nat) elem) | |
(KnownNat len, StaticToAutomatic p elem elem') => StaticToAutomatic (Param_elem p) (Vector (Static Nat len) elem) (Vector (Static Nat len) elem') |
type ApplyConstraint p m = ApplyConstraint_GetConstraint p (ApplyConstraint_GetType p m) Source
type family GetParam p t :: k3 Source
Instances
type GetParam * ((* -> Constraint) -> * -> Constraint) Param_a (Maybe a) = a | |
type GetParam * ((* -> Constraint) -> * -> Constraint) Param_b (Either a b) = b | |
type GetParam * ((* -> Constraint) -> * -> Constraint) Param_a (Either a b) = a | |
type GetParam * ((* -> Constraint) -> * -> Constraint) Param_elem (Vector len elem) = elem | |
type GetParam * (k -> Constraint) (Base k) t = t | |
type GetParam * (* -> Constraint) (Param_a p) (Maybe a) = GetParam * (* -> Constraint) p a | |
type GetParam * (* -> Constraint) (Param_b p) (Either a b) = GetParam * (* -> Constraint) p b | |
type GetParam * (* -> Constraint) (Param_a p) (Either a b) = GetParam * (* -> Constraint) p a | |
type GetParam k (* -> Constraint) (Param_elem p) (Vector len elem) = GetParam k (* -> Constraint) p elem | |
type GetParam (Config Nat) (* -> Constraint) Param_len (Vector len elem) = len |
type family SetParam p a t :: * Source
Instances
type SetParam ((* -> Constraint) -> * -> Constraint) * Param_a newparam (Maybe a) = Maybe newparam | |
type SetParam ((* -> Constraint) -> * -> Constraint) * Param_b newparam (Either a b) = Either a newparam | |
type SetParam ((* -> Constraint) -> * -> Constraint) * Param_a newparam (Either a b) = Either newparam b | |
type SetParam ((* -> Constraint) -> * -> Constraint) * Param_elem newparam (Vector len elem) = Vector len newparam | |
type SetParam (* -> Constraint) * (Param_b p) newparam t = SetParam ((* -> Constraint) -> * -> Constraint) * Param_b (SetParam (* -> Constraint) * p newparam (GetParam * ((* -> Constraint) -> * -> Constraint) Param_b t)) t | |
type SetParam (* -> Constraint) * (Param_a p) newparam t = SetParam ((* -> Constraint) -> * -> Constraint) * Param_a (SetParam (* -> Constraint) * p newparam (GetParam * ((* -> Constraint) -> * -> Constraint) Param_a t)) t | |
type SetParam (* -> Constraint) * (Param_a p) newparam t = SetParam ((* -> Constraint) -> * -> Constraint) * Param_a (SetParam (* -> Constraint) * p newparam (GetParam * ((* -> Constraint) -> * -> Constraint) Param_a t)) t | |
type SetParam (* -> Constraint) k (Param_elem p) newparam t = SetParam ((* -> Constraint) -> * -> Constraint) * Param_elem (SetParam (* -> Constraint) k p newparam (GetParam * ((* -> Constraint) -> * -> Constraint) Param_elem t)) t | |
type SetParam (k -> Constraint) * (Base k) c t = c | |
type SetParam (* -> Constraint) (Config Nat) Param_len newparam (Vector len elem) = Vector newparam elem |
type family SetParam' p a t :: * Source
Instances
type SetParam' (Base *) c t = c | |
type SetParam' (Param_b p) newparam t = SetParam ((* -> Constraint) -> * -> Constraint) * Param_b (SetParam (* -> Constraint) * p newparam (GetParam * ((* -> Constraint) -> * -> Constraint) Param_b t)) t | |
type SetParam' (Param_a p) newparam t = SetParam ((* -> Constraint) -> * -> Constraint) * Param_a (SetParam (* -> Constraint) * p newparam (GetParam * ((* -> Constraint) -> * -> Constraint) Param_a t)) t | |
type SetParam' (Param_a p) newparam t = SetParam ((* -> Constraint) -> * -> Constraint) * Param_a (SetParam (* -> Constraint) * p newparam (GetParam * ((* -> Constraint) -> * -> Constraint) Param_a t)) t | |
type SetParam' (Param_elem p) newparam t = SetParam ((* -> Constraint) -> * -> Constraint) * Param_elem (SetParam (* -> Constraint) * p newparam (GetParam * ((* -> Constraint) -> * -> Constraint) Param_elem t)) t |
type family Objective lens :: * -> Constraint Source
Instances
type Objective (Base *) = Base * | |
type Objective (Param_b p) = Objective_Param_b (Param_b p) | |
type Objective (Param_a p) = Objective_Param_a (Param_a p) | |
type Objective (Param_elem p) |
type family RemoveObjective lens :: * -> Constraint Source
Instances
type RemoveObjective (Param_b p) = RemoveObjective_Param_b (Param_b p) | |
type RemoveObjective (Param_a p) = RemoveObjective_Param_a (Param_a p) | |
type RemoveObjective (Param_elem p) |
Instances
Functor (Base *) t | |
Applicative (Base *) t | |
type GetParam * (k -> Constraint) (Base k) t = t | |
type Objective (Base *) = Base * | |
type SetParam' (Base *) c t = c | |
type SetParam (k -> Constraint) * (Base k) c t = c |
removeObjective :: TypeLens p q -> TypeLens p (RemoveObjective q) Source
type family Zoom p :: k2 Source
Instances
type Zoom (* -> Constraint) (* -> Constraint) (Param_b p) = p | |
type Zoom (* -> Constraint) (* -> Constraint) (Param_a p) = p | |
type Zoom (* -> Constraint) (* -> Constraint) (Param_a p) = p | |
type Zoom (* -> Constraint) (* -> Constraint) (Param_elem p) = p |
type family EyePiece p :: k2 Source
Instances
type EyePiece ((* -> Constraint) -> * -> Constraint) (* -> Constraint) (Param_b p) = Param_b | |
type EyePiece ((* -> Constraint) -> * -> Constraint) (* -> Constraint) (Param_a p) = Param_a | |
type EyePiece ((* -> Constraint) -> * -> Constraint) (* -> Constraint) (Param_a p) = Param_a | |
type EyePiece ((* -> Constraint) -> * -> Constraint) (* -> Constraint) (Param_elem p) = Param_elem |
type family ApplyConstraint_GetType p t :: * Source
Instances
type ApplyConstraint_GetType (* -> Constraint) Param_len (Vector len elem) = Vector len elem | |
type ApplyConstraint_GetType (* -> Constraint) (Param_a _p) (Maybe a) = ApplyConstraint_GetType (* -> Constraint) _p a | |
type ApplyConstraint_GetType (* -> Constraint) (Param_b _p) (Either a b) = ApplyConstraint_GetType (* -> Constraint) _p b | |
type ApplyConstraint_GetType (* -> Constraint) (Param_a _p) (Either a b) = ApplyConstraint_GetType (* -> Constraint) _p a | |
type ApplyConstraint_GetType (* -> Constraint) (Param_elem _p) (Vector len elem) = ApplyConstraint_GetType (* -> Constraint) _p elem |
type family ApplyConstraint_GetConstraint p :: * -> Constraint Source
Instances
type ApplyConstraint_GetConstraint (* -> Constraint) Param_len = Param_len | |
type ApplyConstraint_GetConstraint (* -> Constraint) (Param_b _p) = ApplyConstraint_GetConstraint (* -> Constraint) _p | |
type ApplyConstraint_GetConstraint (* -> Constraint) (Param_a _p) = ApplyConstraint_GetConstraint (* -> Constraint) _p | |
type ApplyConstraint_GetConstraint (* -> Constraint) (Param_a _p) = ApplyConstraint_GetConstraint (* -> Constraint) _p | |
type ApplyConstraint_GetConstraint (* -> Constraint) (Param_elem _p) = ApplyConstraint_GetConstraint (* -> Constraint) _p |
Internal coercion
mkRuleFrac :: Rational -> Q [Dec] Source
intparam :: forall n. KnownNat n => Proxy (n :: Nat) -> Int Source
Use this function for getting the type parameter value from an Int
.
It has proper inlining to ensure that the fromIntegral
gets computed
at compile time.
data Float :: *
Single-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE single-precision type.
Instances
Enum Float | |
Eq Float | |
Floating Float | |
Fractional Float | |
Data Float | |
Num Float | |
Ord Float | |
Real Float | |
RealFloat Float | |
RealFrac Float | |
Show Float | |
Generic Float | |
NFData Float | |
Prim Float | |
Unbox Float | |
PseudoPrim Float | |
Typeable * Float | |
Vector Vector Float | |
MVector MVector Float | |
() :=> (Enum Float) | |
() :=> (Eq Float) | |
() :=> (Floating Float) | |
() :=> (Fractional Float) | |
() :=> (Num Float) | |
() :=> (Ord Float) | |
() :=> (Real Float) | |
() :=> (RealFloat Float) | |
() :=> (RealFrac Float) | |
type Rep Float = D1 D_Float (C1 C_Float (S1 NoSelector (Rec0 Float))) | |
data Vector Float = V_Float (Vector Float) | |
data PseudoPrimInfo Float = PseudoPrimInfo_Float () | |
data MVector s Float = MV_Float (MVector s Float) |
Advanced
The code in this section is only for advanced users when the mkParams
function proves insufficient for some reason.
Getting the types to work out by hand can be rather complicated...
if you must use these functions, then you'll probably need some migraine
medication afterward.
Template haskell generating code
mkParamClass_Star :: String -> Q [Dec] Source
Creates classes of the form
class Param_paramname (p :: * -> Constraint) (t :: *) where
NOTE: this function should probably not be called directly
mkParamClass_Config :: String -> Type -> Q [Dec] Source
Creates classes of the form
class Param_paramname t where getParam_paramname :: t -> paramT {-# INLINE getParam_paramname #-}
NOTE: this function should probably not be called directly
mkTypeLens_Star :: String -> Q [Dec] Source
returns True if the parameter has kind *, False otherwise isStarParam :: String -> Q Bool isStarParam paramname = do info <- TH.reify $ mkName $ Param_++paramname return $ case info of ClassI (ClassD _ _ xs _ _) _ -> length xs == 2
Creates a TypeLens for the given star paramname of the form
_paramname :: TypeLens p (Param_paramname p) _paramname = TypeLens
mkTypeLens_Config :: String -> Q [Dec] Source
Creates a TypeLens for the given config paramname of the form
_paramname :: TypeLens Base Param_paramname _paramname = TypeLens
mkHasDictionary_Star :: String -> Q [Dec] Source
Given the class Param_paramname that indexes a star parameter paramname, create an instance of the form
instance ( HasDictionary p ) => HasDictionary (Param_paramname p) where type ParamType (Param_paramname p) = ParamType p newtype ParamDict (Param_paramname p) = ParamDict_paramname { unParamDict_paramname :: ParamType (Param_paramname) } typeLens2dictConstructor _ = coerceParamDict $ typeLens2dictConstructor (TypeLens::TypeLens Base p) {#- INLINE typeLens2dictConstructor #-}
mkHasDictionary_Config :: String -> Type -> Q [Dec] Source
Given the class Param_paramname that indexes a config parameter paramname create an instance of the form
instance HasDictionary Param_paramname where type ParamType Param_paramname = paramtype newtype ParamDict Param_len = ParamDict_paramname { getParamDict_paramname :: paramtype } typeLens2dictConstructor _ = ParamDict_paramname
mkViewParam_Star :: String -> Name -> Q [Dec] Source
Given star parameter paramname and data type dataname that has parameter paramname, create an instance of the form
instance ( ViewParam p paramname ) => ViewParam (Param_paramname p) (dataname v1 v2 ... paramname ... vk) where viewParam _ _ = viewParam (undefined::TypeLens Base p) (undefined :: paramname)
mkViewParam_Config :: String -> Name -> Q [Dec] Source
Given star parameter paramname and data type dataname that has parameter paramname, create an instance of the form
instance ( Param_paramname (dataname v1 v2 ... paramname ... vk) ) => ViewParam Param_paramname (dataname v1 v2 ... paramname ... vk) where viewParam _ _ = getParam_paramname (undefined::dataname v1 v2 ... paramname ... vk)
mkApplyConstraint_Star :: String -> Name -> Q [Dec] Source
Given star parameter paramname and data type dataname that has parameter paramname, create type instances of the form
type instance ApplyConstraint_GetConstraint (Param_paramname p) = ApplyConstraint_GetConstraint p type instance ApplyConstraint_GetType (Param_paramname p) (dataname v1 v2 ... paramname ... vk) = ApplyConstraint_GetType p paramname
mkApplyConstraint_Config :: String -> Name -> Q [Dec] Source
Given star parameter paramname and data type dataname that has parameter paramname, create type instances of the form
type instance ApplyConstraint_GetConstraint Param_paramname = ApplyConstraint_GetConstraint Param_paramname type instance ApplyConstraint_GetType Param_paramname (dataname v1 v2 ... paramname ... vk) = ApplyConstraint_GetType Param_paramname (dataname v1 v2 ... paramname ... vk)
class Param_Dummy t Source
This class is needed because I can't get type variables to work in "reifyInstances"
mkParamInstance :: String -> Type -> Name -> Q [Dec] Source
creates instances of the form
instance (KnownNat paramName) => Param_paramName (Static paramName) where param_paramName m = fromIntegral $ natVal (Proxy::Proxy paramName)
mkReifiableConstraint :: String -> Q [Dec] Source
helper for mkReifiableConstraints'
mkGettersSetters :: Name -> Q [Dec] Source
Given a data type of the form
data Type v1 v2 ... vk = ...
Then for each type param vi, create instances of the form
type instance GetParam Param_vi (Type ... vi ... ) = vi type instance GetParam (Param_vi p) (Type ... vi ... ) = GetParam p vi
type instance SetParam Param_vi vi' (Type ... vi ... )) = Type ... vi' ... type instance SetParam (Param_vi p) vi' (Type ... vi ... )) = SetParam Param_vi (SetParam p vi' vi) t
type instance Zoom (Param_vi a) = a type instance EyePiece (Param_vi a) = Param_vi
This function requires that the Param_
classes have already been defined.
General parameter classes
These classes were shamelessly stollen from this excellent reflection tutorial. If you want to understand how this library works, that's the place to start.
class ReifiableConstraint p where Source
Methods
reifiedIns :: Reifies s (Def p a) :- p (ConstraintLift p a s) Source
Instances
newtype ConstraintLift p a s Source
Constructors
ConstraintLift | |
Fields
|
Modules
module GHC.TypeLits
module Data.Params.Frac
module Data.Reflection
module Data.Proxy
module Data.Constraint
module Data.Constraint.Unsafe