Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
20 lines (14 sloc) 366 Bytes
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Data.Monoid
newtype AInt = A { unA :: Int }
deriving (Show, Eq, Num)
-- monoid under addition
instance Monoid AInt where
mempty = 0
mappend = (+)
newtype MInt = M { unM :: Int }
deriving (Show, Eq, Num)
-- monoid under multiplication
instance Monoid MInt where
mempty = 1
mappend = (*)