| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Language.Haskell.TH.Instances.Internal
- instances :: QuasiQuoter
- splitInstances :: Dec -> DecsQ
- globalizeClass :: Name -> Q Name
- getClassOps :: Traversable t => t Dec -> Map ParentName (Set Name) -> Q (Map ParentName (Set Name))
- defName :: Dec -> Name
- sigName :: Dec -> Name
- getSuperclassNames :: Name -> Q [Name]
- getClassMethods :: Name -> Q (Set Name)
- getTransitiveSuperclassNames :: Name -> Q (Map Name (Set a))
- occName :: Name -> String
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
splitInstances :: Dec -> DecsQ Source #
Implements the instances quasiquoter ast transform
getClassOps :: Traversable t => t Dec -> Map ParentName (Set Name) -> Q (Map ParentName (Set Name)) Source #
Create a Map of className to method declaration from a list of instance method definitions
getSuperclassNames :: Name -> Q [Name] Source #
reify the names of the direct superclasses for a class name