From 46ea14b8567be49435c9f8bf7a9538212e810078 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Fri, 24 Aug 2018 10:36:03 -0700 Subject: [PATCH] Re-order --- src/Data/Reprinting/Splice.hs | 56 +++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/Data/Reprinting/Splice.hs b/src/Data/Reprinting/Splice.hs index 2a247c229..dc936e7b8 100644 --- a/src/Data/Reprinting/Splice.hs +++ b/src/Data/Reprinting/Splice.hs @@ -1,14 +1,14 @@ module Data.Reprinting.Splice - ( Splice(..) + ( Fragment(..) + , copy + , insert + , defer + , Splice(..) , emit , layout , layouts , space , indent - , Fragment(..) - , copy - , insert - , defer , Whitespace(..) ) where @@ -16,6 +16,29 @@ import Data.Reprinting.Token import Data.Sequence (singleton, fromList) import Prologue hiding (Element) +-- | An intermediate representation of concrete syntax in the reprinting pipeline. +data Fragment + = Verbatim Text + -- ^ Verbatim copy of original 'Text' (un-refactored). + | New Element [Context] Text + -- ^ New 'Text' to be inserted, along with original 'Element' and `Context` + -- allowing later steps to re-write. + | Defer Element [Context] + -- ^ To be handled further down the pipeline. + deriving (Eq, Show) + +-- | Copy along some original, un-refactored 'Text'. +copy :: Text -> Seq Fragment +copy = singleton . Verbatim + +-- | Construct an 'New' datum. +insert :: Element -> [Context] -> Text -> Seq Fragment +insert el c = singleton . New el c + +-- | Construct an 'Defer' splice. +defer :: Element -> [Context] -> Seq Fragment +defer el = singleton . Defer el + -- | The final representation of concrete syntax in the reprinting pipeline. data Splice = Emit Text @@ -44,29 +67,6 @@ indent times | times > 0 = stimes times (layout Indent) | otherwise = mempty --- | An intermediate representation of concrete syntax in the reprinting pipeline. -data Fragment - = Verbatim Text - -- ^ Verbatim copy of original 'Text' (un-refactored). - | New Element [Context] Text - -- ^ New 'Text' to be inserted, along with original 'Element' and `Context` - -- allowing later steps to re-write. - | Defer Element [Context] - -- ^ To be handled further down the pipeline. - deriving (Eq, Show) - --- | Copy along some original, un-refactored 'Text'. -copy :: Text -> Seq Fragment -copy = singleton . Verbatim - --- | Construct an 'New' datum. -insert :: Element -> [Context] -> Text -> Seq Fragment -insert el c = singleton . New el c - --- | Construct an 'Defer' splice. -defer :: Element -> [Context] -> Seq Fragment -defer el = singleton . Defer el - -- | Indentation, spacing, and other whitespace. data Whitespace = HardWrap