Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Kleisli endo-morphisms are an instance of Monoid.
{-# LANGUAGE FlexibleInstances, OverlappingInstances #-}
module Main where
import Data.Monoid
import Control.Monad
instance Monad m => Monoid (a -> m a) where
mempty = return
mappend = (>=>)
main :: IO ()
main = do
let m = \x -> [x * 2, x * 3]
let m' = \x -> [x + 1, x, x - 1]
let mm' = m `mappend` mempty `mappend` m'
print $ mm' 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.