on master help sign in
Monoid instance for page
f104f91Jasper Van der Jeugt
src/Hakyll/Web/Page/Internal.hs+7
@@ -6,10 +6,12 @@ module Hakyll.Web.Page.Internal
6 ) where
6 ) where
7
7
8import Control.Applicative ((<$>), (<*>))
8import Control.Applicative ((<$>), (<*>))
9+import Data.Monoid (Monoid, mempty, mappend)
9
10
10import Data.Map (Map)
11import Data.Map (Map)
11import Data.Binary (Binary, get, put)
12import Data.Binary (Binary, get, put)
12import Data.Typeable (Typeable)
13import Data.Typeable (Typeable)
14+import qualified Data.Map as M
13
15
14import Hakyll.Core.Writable
16import Hakyll.Core.Writable
15
17
@@ -20,6 +22,11 @@ data Page a = Page
20 , pageBody :: a
22 , pageBody :: a
21 } deriving (Show, Typeable)
23 } deriving (Show, Typeable)
22
24
25+instance Monoid a => Monoid (Page a) where
26+ mempty = Page M.empty mempty
27+ mappend (Page m1 b1) (Page m2 b2) =
28+ Page (M.union m1 m2) (mappend b1 b2)
29+
23instance Functor Page where
30instance Functor Page where
24 fmap f (Page m b) = Page m (f b)
31 fmap f (Page m b) = Page m (f b)
25
32