úÎ)/'      non-portable experimentalsjoerd@w3future.comNone An algebra f a -> a corresponds to an instance of a of the class Class f. h In some cases, for example for tuple types, you can give an algebra generically for every signature: ; instance (Class f m, Class f n) => Algebra f (m, n) where D algebra fmn = (evaluate (fmap fst fmn), evaluate (fmap snd fmn)) The class for which f is the signature. HTranslate the operations of the signature to method calls of the class. fIf you just want to applicatively lift existing instances, you can use this default implementation of .     non-portable experimentalsjoerd@w3future.comNone+Derive a signature for an algebraic class.  For example:   deriveSignature ''Monoid (The above would generate the following:  F data MonoidSignature a = Op_mempty | Op_mappend a a | Op_mconcat [a] < deriving (Functor, Foldable, Traversable, Show, Eq, Ord) 1 instance AlgebraSignature MonoidSignature where ' type Class MonoidSignature = Monoid  evaluate Op_mempty = mempty + evaluate (Op_mappend a b) = mappend a b + evaluate (Op_mconcat ms) = mconcat ms ? creates the signature data type and an instance for it of the   class. DeriveTraversable is used the generate the ! instance of the signature. MThis will do nothing if there is already a signature for the class in scope. +Derive an instance for an algebraic class.  For example:  4 deriveInstance [t| (Num m, Num n) => Num (m, n) |] %To be able to derive an instance for a of class c, we need an instance of  f a,  where f is the signature of c. L will generate a signature for the class if there is no signature in scope. ODerive an instance for an algebraic class with a given partial implementation.  For example: 8 deriveInstanceWith [t| Num n => Num (Integer -> n) |]  [d| + fromInteger x y = fromInteger (x + y)  |] ODerive an instance for an algebraic class with a given partial implementation,  but don'Pt generate the signature. This is for when you want to derive several instances  of the same class, but can',t splice the results directly. In that case   can'9t detect it has already generated the signature earlier.  "#$%&'()    "#$%&'() non-portable experimentalsjoerd@w3future.comNone*       !"#$%&'()*+,-.algebraic-classes-0.4Data.Algebra.InternalData.Algebra.TH Data.AlgebraAlgebraalgebraAlgebraSignatureClassevaluatealgebraA OperationTH functionName operationNamearity constructorfixity SignatureTH signatureName typeVarName operationsgetSignatureInfoderiveSignaturederiveInstancederiveInstanceWith deriveInstanceWith_skipSignaturebuildSignatureDataTypesignatureInstances$fAlgebrafConst $fAlgebrafSTM$fAlgebrafEither$fAlgebrafMaybe $fAlgebrafIO$fAlgebraf(->) $fAlgebraf(,) $fAlgebraf()baseData.Traversable TraversablederiveInstanceWith'deriveInstanceWith''buildOperation changeName mkArgList renameAllrenameprependC