Safe Haskell | None |
---|---|
Language | Haskell2010 |
Various internal utilities for beam-th. The usual caveats apply.
- newtype MakeTableT m a = MakeTableT {}
- type MakeTable a = MakeTableT Identity a
- type MakeTableT' a = MakeTableT Q a
- type MakeTableT'' = MakeTableT' ()
- runTableT :: Name -> VarBangType -> MakeTableT' a -> DecsQ
- tellD :: MonadWriter [Dec] m => Dec -> m ()
- vst :: MonadReader (Name, VarBangType) m => m VarBangType
- name :: MonadReader (Name, VarBangType) m => m Name
- nameId :: MonadReader (Name, VarBangType) m => m Name
- nameId' :: MonadReader (Name, VarBangType) m => m Name
- nameT :: MonadReader (Name, VarBangType) m => m Name
- rename :: (String -> String) -> Name -> Name
- (<~>) :: Type -> Type -> Type
- (<+>) :: Exp -> Exp -> Exp
- (~>) :: Type -> Type -> Type
- invalidConstructor :: MonadFail m => m a
- assert :: Bool -> String -> Q ()
- assertMany :: [(Bool, String)] -> Q ()
The MakeTableT monad transformer
Definition
newtype MakeTableT m a Source #
A monad transformer for writing Template Haskell declarations.
The Reader contains both the base name of the table and the VarBangType
of the primary key field.
If you can come up with a better name, drop me a line.
MonadTrans MakeTableT Source # | |
Monad m => Monad (MakeTableT m) Source # | |
Functor m => Functor (MakeTableT m) Source # | |
MonadFail m => MonadFail (MakeTableT m) Source # | |
Applicative m => Applicative (MakeTableT m) Source # | |
Monad m => MonadWriter [Dec] (MakeTableT m) Source # | |
Monad m => MonadReader (Name, VarBangType) (MakeTableT m) Source # | |
Derived type synonyms
type MakeTable a = MakeTableT Identity a Source #
Type synonym for MakeTableT
in the Identity
monad.
Only defined for complying with the monad transformer conventions and not actually used.
type MakeTableT' a = MakeTableT Q a Source #
Type synonym for MakeTableT
in the Q
monad.
type MakeTableT'' = MakeTableT' () Source #
Type synonym for MakeTableT
in the Q
monad with the empty tuple as the inner type.
This is the most common use case.
Helper functions
:: Name | The base name of the table, without the trailing "T". |
-> VarBangType | The primary key field. |
-> MakeTableT' a | The table writing sequence to be executed. The inner type is ignored. |
-> DecsQ |
Run the table writing sequence (or, the MakeTableT
if you prefer).
Extracting values from a MakeTableT
vst :: MonadReader (Name, VarBangType) m => m VarBangType Source #
Extract the PrimaryKey
VarBangType
Simple and composite names
name :: MonadReader (Name, VarBangType) m => m Name Source #
Get the base name
nameId :: MonadReader (Name, VarBangType) m => m Name Source #
Get the name with an "Id" suffix
nameId' :: MonadReader (Name, VarBangType) m => m Name Source #
Get the name with an "Id'" suffix
nameT :: MonadReader (Name, VarBangType) m => m Name Source #
Get the name with a "T" suffix
Name utilities
Type and Expression Application Sugar
(<~>) :: Type -> Type -> Type infixl 6 Source #
Convenient syntactic sugar for application of types.
>>>
ConT nm <~> ConT nm <~> ConT nm
AppT (AppT (ConT nm) (ConT nm)) (ConT nm)
(<+>) :: Exp -> Exp -> Exp infixl 6 Source #
Convenient syntactic sugar for application of expressions.
>>>
ConE nm <+> ConE nm <+> ConE nm
AppE (AppE (ConE nm) (ConE nm)) (ConE nm)
(~>) :: Type -> Type -> Type infixl 6 Source #
Convenient syntactic sugar for arrows in types.
>>>
StarT ~> StarT
AppT (AppT ArrowT StarT) StarT
Error handling
Constructor types
invalidConstructor :: MonadFail m => m a Source #
Complain about an unknown field in the table.