From 4dec972cfe6827f4c7a40cf1c50e4a0120d4e442 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 5 Feb 2012 14:25:12 -0800 Subject: Remove dependency on dlist. Use sequence in Pretty instead. --- src/Text/Pandoc/Pretty.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs index b06f2f384..340afeeed 100644 --- a/src/Text/Pandoc/Pretty.hs +++ b/src/Text/Pandoc/Pretty.hs @@ -72,7 +72,8 @@ module Text.Pandoc.Pretty ( ) where -import Data.DList (DList, fromList, toList, cons, singleton) +import Data.Sequence (Seq, fromList, (<|), singleton) +import Data.Foldable (toList) import Data.List (intercalate) import Data.Monoid import Data.String @@ -102,7 +103,7 @@ data D = Text Int String | BlankLine deriving (Show) -newtype Doc = Doc { unDoc :: DList D } +newtype Doc = Doc { unDoc :: Seq D } deriving (Monoid) instance Show Doc where @@ -342,12 +343,12 @@ offsetOf _ = 0 -- | A literal string. text :: String -> Doc text = Doc . toChunks - where toChunks :: String -> DList D + where toChunks :: String -> Seq D toChunks [] = mempty toChunks s = case break (=='\n') s of - ([], _:ys) -> NewLine `cons` toChunks ys - (xs, _:ys) -> Text (realLength xs) xs `cons` - NewLine `cons` toChunks ys + ([], _:ys) -> NewLine <| toChunks ys + (xs, _:ys) -> Text (realLength xs) xs <| + (NewLine <| toChunks ys) (xs, []) -> singleton $ Text (realLength xs) xs -- | A character. -- cgit v1.2.3