From d0a7dbd948351a6622a4d670bfbb8ef622e6278f Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Wed, 28 Mar 2018 15:49:50 +0300 Subject: Muse writer: implement Default for WriterState --- src/Text/Pandoc/Writers/Muse.hs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs index 74251a3bd..b03ce8f90 100644 --- a/src/Text/Pandoc/Writers/Muse.hs +++ b/src/Text/Pandoc/Writers/Muse.hs @@ -47,6 +47,7 @@ import Prelude import Control.Monad.Reader import Control.Monad.State.Strict import Data.Char (isSpace, isDigit, isAsciiUpper, isAsciiLower) +import Data.Default import Data.Text (Text) import Data.List (intersperse, transpose, isInfixOf) import System.FilePath (takeExtension) @@ -76,6 +77,11 @@ data WriterState = , stIds :: Set.Set String } +instance Default WriterState + where def = WriterState { stNotes = [] + , stIds = Set.empty + } + evalMuse :: PandocMonad m => Muse m a -> WriterEnv -> WriterState -> m a evalMuse document env st = evalStateT (runReaderT document env) st @@ -85,14 +91,11 @@ writeMuse :: PandocMonad m -> Pandoc -> m Text writeMuse opts document = - evalMuse (pandocToMuse document) env st - where env = WriterEnv { envOptions = opts - , envTopLevel = True - , envInsideBlock = False - } - st = WriterState { stNotes = [] - , stIds = Set.empty - } + evalMuse (pandocToMuse document) env def + where env = WriterEnv { envOptions = opts + , envTopLevel = True + , envInsideBlock = False + } -- | Return Muse representation of document. pandocToMuse :: PandocMonad m -- cgit v1.2.3