summaryrefslogtreecommitdiff
path: root/src/Hakyll/Web/Page/Internal.hs
blob: bac4c511402049e16123ca4472db575b51acef95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
-- | Internal representation of the page datatype
--
{-# LANGUAGE DeriveDataTypeable #-}
module Hakyll.Web.Page.Internal
    ( Page (..)
    ) where

import Control.Applicative ((<$>), (<*>))

import Data.Map (Map)
import Data.Binary (Binary, get, put)
import Data.Typeable (Typeable)

import Hakyll.Core.Writable

-- | Type used to represent pages
--
data Page a = Page
    { pageMetadata :: Map String String
    , pageBody     :: a
    } deriving (Show, Typeable)

instance Functor Page where
    fmap f (Page m b) = Page m (f b)

instance Binary a => Binary (Page a) where
    put (Page m b) = put m >> put b
    get = Page <$> get <*> get

instance Writable a => Writable (Page a) where
    write p (Page _ b) = write p b