Safe Haskell | None |
---|---|
Language | Haskell2010 |
TypeMachine.TH.Is
Documentation
isClassName :: Name -> Name Source #
Get the name of the Is
class generated for the given type
> isClassName ''User IsUser
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 ...
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 ...