From 27ff2eef890d86001c0210dd2d20639d34fbd32c Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Tue, 28 Dec 2010 11:12:45 +0100 Subject: Use Typeable instead of ADT --- src/Hakyll/Web/FileType.hs | 2 +- src/Hakyll/Web/Page.hs | 4 +++- src/Hakyll/Web/Pandoc.hs | 18 +++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src/Hakyll/Web') 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 -- cgit v1.2.3