summaryrefslogtreecommitdiff
path: root/src/Hakyll/Web/Page
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-12-30 21:18:55 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-12-30 21:18:55 +0100
commite49cd3b4b071c2e0cb3e553fe8272e7cd2843349 (patch)
tree544d8f29ca8082577426010b7f251185a209e3f4 /src/Hakyll/Web/Page
parentda12825066d16884bae2f884029102919dd9a558 (diff)
downloadhakyll-e49cd3b4b071c2e0cb3e553fe8272e7cd2843349.tar.gz
Cleanup, split up page module
Diffstat (limited to 'src/Hakyll/Web/Page')
-rw-r--r--src/Hakyll/Web/Page/Internal.hs31
-rw-r--r--src/Hakyll/Web/Page/Read.hs2
2 files changed, 32 insertions, 1 deletions
diff --git a/src/Hakyll/Web/Page/Internal.hs b/src/Hakyll/Web/Page/Internal.hs
new file mode 100644
index 0000000..bac4c51
--- /dev/null
+++ b/src/Hakyll/Web/Page/Internal.hs
@@ -0,0 +1,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
diff --git a/src/Hakyll/Web/Page/Read.hs b/src/Hakyll/Web/Page/Read.hs
index 82224a4..d72f32a 100644
--- a/src/Hakyll/Web/Page/Read.hs
+++ b/src/Hakyll/Web/Page/Read.hs
@@ -11,7 +11,7 @@ import Data.List (isPrefixOf)
import Data.Map (Map)
import qualified Data.Map as M
-import Hakyll.Web.Page
+import Hakyll.Web.Page.Internal
import Hakyll.Web.Util.String
-- | We're using a simple state monad as parser