cluss-0.2: simple alternative to type classes

Copyright(c) Yusuke Matsushita 2014
LicenseBSD3
MaintainerYusuke Matsushita
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Type.Cluss.TH

Description

Template haskell tools for clusses.

Basic tools are in the module Type.Cluss.

Synopsis

Documentation

clussify :: Name -> Q Type Source

clussify converts a type class into a cluss, roughly speaking. For example, if the visible instances of Show were to be only Show Int, Show a => Show [a], and (Show a, Show b) => Show (a, b), the result of $(clussify ''Show) will be

Show >|< In [Type Int, Unary [] Show, Binary (,) (Show >|< Show)]

(in fact, the result will be more verbose, using Show >|< Pure >++< Pure >|< Show instead of Show >|< Show).

Due to the stage restriction of template haskell, clussify can't catch the instances defined in the module where the classify is written.

Note that clussify neglects complicated instances that cannot be simply expressed with the combinators in the module Type.Cluss.

You need some language extensions to use clussify. Basically, this language pragma will do.

{-# LANGUAGE TemplateHaskell, ConstraintKinds #-}