úÎ41²"      !(c) Sjoerd Visscher 2013 BSD-style (see the file LICENSE)sjoerd@w3future.com experimental non-portableNone &357>L An algebra f a -> a corresponds to an instance of a of the class Class fi. 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 algebra fmn = (evaluate (fmap fst fmn), evaluate (fmap snd fmn))The class for which f is the signature.GTranslate the operations of the signature to method calls of the class.%The signature datatype for the class c.fIf you just want to applicatively lift existing instances, you can use this default implementation of .    (c) Sjoerd Visscher 2013 BSD-style (see the file LICENSE)sjoerd@w3future.com experimental non-portableNone:Derive a signature for an algebraic class. For example: deriveSignature ''Monoid'The above would generate the following: ÿîdata MonoidSignature a = Op_mempty | Op_mappend a a | Op_mconcat [a] deriving (Functor, Foldable, Traversable, Eq, Ord) type instance Signature Monoid = MonoidSignature 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 instance Show a => Show (MonoidSignature a) where showsPrec d Op_mempty = showParen (d > 10) $ showString "mempty" showsPrec d (Op_mappend a1 a2) = showParen (d > 10) $ showString "mappend" . showChar ' ' . showsPrec 11 a1 . showChar ' ' . showsPrec 11 a2 showsPrec d (Op_mconcat a1) = showParen (d > 10) $ showString "mconcat" . showChar ' ' . showsPrec 11 a1B creates the signature data type and an instance for it of the  class. DeriveTraversable is used the generate the " instance of the signature.LThis will do nothing if there is already a signature for the class in scope.:Derive an instance for an algebraic class. For example: 2deriveInstance [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.K will generate a signature for the class if there is no signature in scope.^Derive an instance for an algebraic class with a given partial implementation. For example: jderiveInstanceWith [t| Num n => Num (Integer -> n) |] [d| fromInteger x y = fromInteger (x + y) |]ôDerive an instance for an algebraic class with a given partial implementation, but don't 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't detect it has already generated the signature earlier.#$ !%&'()*+,- ! !#$ !%&'()*+,-(c) Sjoerd Visscher 2013 BSD-style (see the file LICENSE)sjoerd@w3future.com experimental non-portableNone &-./7>L  .      !"#$%&'()*+,-./012algeb_CWQOdJZPeuw5nLR46w6iUxData.Algebra.InternalData.Algebra.TH Data.AlgebraAlgebraalgebraAlgebraSignatureClassevaluate SignaturealgebraA$fAlgebrafConst $fAlgebrafSTM$fAlgebrafEither$fAlgebrafMaybe $fAlgebrafIO$fAlgebraf(->) $fAlgebraf(,) $fAlgebraf() OperationTH functionName operationNamearity constructorfixity SignatureTH signatureName typeVarName operationsgetSignatureInfoderiveSignaturederiveInstancederiveInstanceWith deriveInstanceWith_skipSignaturebuildSignatureDataTypesignatureInstancesbaseData.Traversable TraversablederiveInstanceWith'deriveInstanceWith''buildOperation changeName addPrefix isOperator mkArgList renameAllrenameprependCtvName