subhask- Type safe interface for programming in subcategories of Hask

Safe HaskellNone



This file contains the template haskell code for deriving SubHask class instances from Base instances. All of the standard instances are created in SubHask.Compatibility.Base. This module is exported so that you can easily make instances for your own types without any extra work. To do this, just put the line


at the bottom of your file. Any types in scope that do not already have SubHask instances will have them created automatically.

FIXME: Most classes aren't implemented yet. I don't want to go through the work until their definitions stabilize somewhat.



deriveAll :: Q [Dec] Source

Derives instances for all data types in scope. This is the only function you should need to use. The other functions are exported only for debugging purposes if this function should fail.

forAllInScope :: Name -> (Cxt -> Q Type -> Q [Dec]) -> Q [Dec] Source

Constructs an instance using the given function for everything in scope.

runIfNotInstance :: Name -> Type -> Q [Dec] -> Q [Dec] Source

This is an internal helper function. It prevents us from defining two instances for the same class/type pair.

mkPreludeEq :: Cxt -> Q Type -> Q [Dec] Source

Create an Eq instance from a Prelude.Eq instance.

mkPreludeFunctor :: Cxt -> Q Type -> Q [Dec] Source

Create a Functor instance from a Prelude.Functor instance.

mkPreludeApplicative :: Cxt -> Q Type -> Q [Dec] Source

Create an Applicative instance from a Prelude.Applicative instance.

mkPreludeMonad :: Cxt -> Q Type -> Q [Dec] Source

Create a Monad instance from a Prelude.Monad instance.

FIXME: Monad transformers still require their parameter monad to be an instance of Prelude.Monad.