Last active
December 17, 2015 15:59
-
-
Save khibino/5635382 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, TypeOperators #-} | |
module Monoid where | |
import Data.Monoid (Monoid, Sum, Product) | |
import qualified Data.Monoid as M | |
import Control.Category | |
class Category (-->) => CategoricalMonoid (-->) m where | |
mempty :: m | |
(<>) :: m --> (m --> m) | |
class (CategoricalMonoid (-->) m, CategoricalMonoid (-->) n) | |
=> MonoidHomomorphism (-->) f m n where | |
mapMH :: f (m --> m --> m) (n --> n --> n) | |
instance Monoid m => CategoricalMonoid (->) m where | |
mempty = M.mempty | |
(<>) = (M.<>) | |
newtype Pow a b = Pow ((a -> (a -> a)) -> | |
(b -> (b -> b))) | |
instance Integral a => MonoidHomomorphism (->) Pow (Sum a) (Product a) where | |
mapMH = Pow $ const (<>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment