fixie-0.0.0: Opininated testing framework for mtl style (spies, stubs, and mocks)

Safe HaskellNone
LanguageHaskell2010

Test.Fixie.TH

Synopsis

Documentation

mkFixture :: String -> [Type] -> Q [Dec] Source #

A Template Haskell function that generates a fixture record type with a given name that reifies the set of typeclass dictionaries provided, as described in the module documentation for Control.Monad.Fixie.TH. For example, the following splice would create a new record type called Fixture with fields and instances for typeclasses called Foo and Bar:

mkFixture "Fixture" [ts| Foo, Bar |]

mkFixture supports types in the same format that deriving clauses do when used with the GeneralizedNewtypeDeriving GHC extension, so deriving multi-parameter typeclasses is possible if they are partially applied. For example, the following is valid:

class MultiParam a m where
  doSomething :: a -> m ()

mkFixture "Fixture" [ts| MultiParam String |]

def :: Default a => a #

The default value for this type.

ts :: QuasiQuoter Source #

A quasi-quoter like the built-in [t| ... |] quasi-quoter, but produces a list of types instead of a single type. Each type should be separated by a comma.

>>> [ts| Bool, (), String |]
[ConT GHC.Types.Bool,ConT GHC.Tuple.(),ConT GHC.Base.String]
>>> [ts| Maybe Int, Monad m |]
[AppT (ConT GHC.Base.Maybe) (ConT GHC.Types.Int),AppT (ConT GHC.Base.Monad) (VarT m)]