Îõ³h$Ks*      !"#$%&'()(c) Sjoerd Visscher 2013 BSD-style (see the file LICENSE)sjoerd@w3future.com experimental non-portableNone ->ÀÁÂÉ×algebraic-classes An algebra f a -> a corresponds to an instance of a of the class Class fé. 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))algebraic-classesThe class for which f is the signature.algebraic-classesÇTranslate the operations of the signature to method calls of the class.algebraic-classes%The signature datatype for the class c.algebraic-classesæIf 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Ñà”#algebraic-classes: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 a1# creates the signature data type and an instance for it of the  class. DeriveTraversable is used the generate the * instance of the signature.ÌThis will do nothing if there is already a signature for the class in scope.$algebraic-classes: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.$Ë will generate a signature for the class if there is no signature in scope.%algebraic-classesÞDerive an instance for an algebraic class with a given partial implementation. For example: êderiveInstanceWith [t| Num n => Num (Integer -> n) |] [d| fromInteger x y = fromInteger (x + y) |]&algebraic-classesô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.'algebraic-classes®Derive the instances for the superclasses too, all using the same context. Usually you'd want to do this manually since you can often give a stricter context, for example: ÒderiveSuperclassInstances [t| (Fractional m, Fractional n) => Fractional (m, n) |]will derive an instance *(Fractional m, Fractional n) => Num (m, n)" while the instance only needs (Num m, Num n). !"#$%&'()$%&'# !"()(c) Sjoerd Visscher 2013 BSD-style (see the file LICENSE)sjoerd@w3future.com experimental non-portableNone -567ÁÂÉ×] $% $%+      !"#$%&'()*+,-.algebraic-classes-0.9.4-inplaceData.Algebra.InternalData.Algebra.TH Data.AlgebraAlgebraalgebraAlgebraSignatureClassevaluate SignaturealgebraA$fAlgebrafConst $fAlgebrafAp $fAlgebrafSTM$fAlgebrafEither$fAlgebrafMaybe $fAlgebrafIO $fAlgebraf-> $fAlgebraf(,) $fAlgebraf() SuperclassTHsuperclassName constrName signatureTH OperationTH functionName operationNamearity constructorfixity SignatureTH signatureName typeVarName operations superclassesgetSignatureInfoderiveSignaturederiveInstancederiveInstanceWith deriveInstanceWith_skipSignaturederiveSuperclassInstancesbuildSignatureDataTypesignatureInstancesbaseData.Traversable Traversable