mirror of
https://github.com/github/semantic.git
synced 2024-11-30 14:47:30 +03:00
Re-order
This commit is contained in:
parent
e9e8edbebe
commit
46ea14b856
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user