summaryrefslogtreecommitdiff
path: root/src/Hakyll/Web
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-12-28 11:12:45 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-12-28 11:12:45 +0100
commit27ff2eef890d86001c0210dd2d20639d34fbd32c (patch)
tree8a6c7fcce735ce99d49e7511f8bac0b8829a70a2 /src/Hakyll/Web
parent6ffb83d46f0e1e82c38fa959464a98f6087f417f (diff)
downloadhakyll-27ff2eef890d86001c0210dd2d20639d34fbd32c.tar.gz
Use Typeable instead of ADT
Diffstat (limited to 'src/Hakyll/Web')
-rw-r--r--src/Hakyll/Web/FileType.hs2
-rw-r--r--src/Hakyll/Web/Page.hs4
-rw-r--r--src/Hakyll/Web/Pandoc.hs18
3 files changed, 13 insertions, 11 deletions
diff --git a/src/Hakyll/Web/FileType.hs b/src/Hakyll/Web/FileType.hs
index 4da1439..a958fed 100644
--- a/src/Hakyll/Web/FileType.hs
+++ b/src/Hakyll/Web/FileType.hs
@@ -51,5 +51,5 @@ fileType = fileType' . takeExtension
-- | Get the file type for the current file
--
-getFileType :: TargetM a FileType
+getFileType :: TargetM FileType
getFileType = fileType . toFilePath <$> getIdentifier
diff --git a/src/Hakyll/Web/Page.hs b/src/Hakyll/Web/Page.hs
index 92303c1..78178cb 100644
--- a/src/Hakyll/Web/Page.hs
+++ b/src/Hakyll/Web/Page.hs
@@ -2,6 +2,7 @@
-- type 'String') and number of metadata fields. This type is used to represent
-- pages on your website.
--
+{-# LANGUAGE DeriveDataTypeable #-}
module Hakyll.Web.Page
( Page (..)
, toMap
@@ -12,6 +13,7 @@ import Control.Applicative ((<$>), (<*>))
import Data.Map (Map)
import qualified Data.Map as M
import Data.Binary (Binary, get, put)
+import Data.Typeable (Typeable)
import Hakyll.Core.Writable
@@ -20,7 +22,7 @@ import Hakyll.Core.Writable
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)
diff --git a/src/Hakyll/Web/Pandoc.hs b/src/Hakyll/Web/Pandoc.hs
index 57fd1ac..17cac81 100644
--- a/src/Hakyll/Web/Pandoc.hs
+++ b/src/Hakyll/Web/Pandoc.hs
@@ -29,9 +29,9 @@ import Hakyll.Web.Page
-- | Read a string using pandoc, with the default options
--
-readPandoc :: FileType -- ^ File type, determines how parsing happens
- -> String -- ^ String to read
- -> Pandoc -- ^ Resulting document
+readPandoc :: FileType -- ^ File type, determines how parsing happens
+ -> String -- ^ String to read
+ -> Pandoc -- ^ Resulting document
readPandoc = readPandocWith defaultParserState
-- | Read a string using pandoc, with the supplied options
@@ -51,8 +51,8 @@ readPandocWith state fileType' = case fileType' of
-- | Write a document (as HTML) using pandoc, with the default options
--
-writePandoc :: Pandoc -- ^ Document to write
- -> String -- ^ Resulting HTML
+writePandoc :: Pandoc -- ^ Document to write
+ -> String -- ^ Resulting HTML
writePandoc = writePandocWith defaultWriterOptions
-- | Write a document (as HTML) using pandoc, with the supplied options
@@ -64,19 +64,19 @@ writePandocWith = P.writeHtmlString
-- | Read the resource using pandoc
--
-pageReadPandoc :: Page String -> TargetM a (Page Pandoc)
+pageReadPandoc :: Page String -> TargetM (Page Pandoc)
pageReadPandoc = pageReadPandocWith defaultParserState
-- | Read the resource using pandoc
--
-pageReadPandocWith :: P.ParserState -> Page String -> TargetM a (Page Pandoc)
+pageReadPandocWith :: P.ParserState -> Page String -> TargetM (Page Pandoc)
pageReadPandocWith state page = do
fileType' <- getFileType
return $ readPandocWith state fileType' <$> page
-- | Render the resource using pandoc
--
-pageRenderPandoc :: Page String -> TargetM a (Page String)
+pageRenderPandoc :: Page String -> TargetM (Page String)
pageRenderPandoc = pageRenderPandocWith defaultParserState defaultWriterOptions
-- | Render the resource using pandoc
@@ -84,7 +84,7 @@ pageRenderPandoc = pageRenderPandocWith defaultParserState defaultWriterOptions
pageRenderPandocWith :: P.ParserState
-> P.WriterOptions
-> Page String
- -> TargetM a (Page String)
+ -> TargetM (Page String)
pageRenderPandocWith state options page = do
pandoc <- pageReadPandocWith state page
return $ writePandocWith options <$> pandoc