Safe Haskell | None |
---|---|
Language | Haskell2010 |
TypeMachine
Synopsis
- type_ :: String -> TM Type -> Q [Dec]
- module TypeMachine.Functions
- defineIs :: Name -> Q [Dec]
- deriveIs :: Name -> Name -> Q [Dec]
- (<:>) :: LiftableTMFunction (a -> b) => (a -> b) -> TM a -> b
- (<::>) :: LiftableTMFunction (Type -> a) => (Type -> a) -> Name -> a
- data Type
- type TM a = WriterT [TypeMachineLog] Q a
Entrypoint
type_ :: String -> TM Type -> Q [Dec] Source #
Entrypoint of TypeMachine. Create a new data type using a TM
computation
Main Type Functions
module TypeMachine.Functions
Is
defineIs :: Name -> Q [Dec] Source #
Define the Is
class for the given type and generate the To
function
> data User = User { id :: Int, name :: String } > defineIs ''User class IsUser a where getId :: a -> Int getName :: a -> String setId :: Int -> a -> a setName :: String -> a -> a toUser :: (IsUser a) => a -> User toUser a = User (getId a) (getName a) instance IsUser User where ...
deriveIs :: Name -> Name -> Q [Dec] Source #
Returns the declaration of the instance of Is
for a given type
> deriveIs ''Animal ''Dog instance IsAnimal Dog where ...
Infixes
(<:>) :: LiftableTMFunction (a -> b) => (a -> b) -> TM a -> b Source #
Internal types
Data structure to easily manipulate Template Haskell's DataD