Monoid instance for page

This commit is contained in:
Jasper Van der Jeugt 2011-01-18 23:57:58 +01:00
parent 0bbc01f012
commit f104f91182

View file

@ -6,10 +6,12 @@ module Hakyll.Web.Page.Internal
) where
import Control.Applicative ((<$>), (<*>))
import Data.Monoid (Monoid, mempty, mappend)
import Data.Map (Map)
import Data.Binary (Binary, get, put)
import Data.Typeable (Typeable)
import qualified Data.Map as M
import Hakyll.Core.Writable
@ -20,6 +22,11 @@ data Page a = Page
, pageBody :: a
} deriving (Show, Typeable)
instance Monoid a => Monoid (Page a) where
mempty = Page M.empty mempty
mappend (Page m1 b1) (Page m2 b2) =
Page (M.union m1 m2) (mappend b1 b2)
instance Functor Page where
fmap f (Page m b) = Page m (f b)