| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Language.Haskell.TH.Instances
Documentation
instances :: QuasiQuoter Source #
QuasiQuoter for providing intrinsic-superclasses.
Example:
class Semigroup a where mappend :: a -> a -> a
class Semigroup a => Commutative a
class Semigroup a => Monoid a where mempty :: a
class Monoid a => Group a where inverse :: a -> a
class (Commutative a, Group a) => CommutativeGroup a
[instances| Num a => CommutativeGroup a where
mempty = fromInteger 0
mappend a b = a + b
inverse = negate
|]will generate the appropriate instances for Semigroup, Monoid, and Group:
instance Num a => Semigroup a where mappend a b = a + b instance Num a => Commutative a instance Num a => Monoid a where mempty = fromInteger 0 instance Num a => Group a where inverse = negate instance Num a => CommutativeGroup a