Add indent.
authorJulien Moutinho <julm+symantic@autogeree.net>
Fri, 9 Mar 2018 01:38:12 +0000 (02:38 +0100)
committerJulien Moutinho <julm+symantic@autogeree.net>
Fri, 9 Mar 2018 01:38:12 +0000 (02:38 +0100)
symantic-document/Language/Symantic/Document/Sym.hs
symantic-document/Language/Symantic/Document/Term.hs
symantic-document/Language/Symantic/Document/Term/Dimension.hs
symantic-document/Language/Symantic/Document/Term/IO.hs
symantic/Language/Symantic/Typing/Document.hs

index a629024696f8eedee2c79c8d9b6807123f544159..7826adc759fd93b0d69266020dc95f9fe53427a0 100644 (file)
@@ -133,6 +133,8 @@ class Textable d => Alignable d where
        newlineWithIndent    :: d
        -- | @('column' f)@ write @f@ applied to the current 'Column'.
        column :: (Column -> d) -> d
+       -- | @('indent' f)@ write @f@ applied to the current 'Indent'.
+       indent :: (Indent -> d) -> d
        -- | @('endToEndWidth' d f)@ write @d@ then
        -- @f@ applied to the difference between
        -- the end 'Column' and start 'Column' of @d@.
index b296131c5e6e39a27bd407afb7fa0a6e7eb0b11d..27ffc5a11c1d2ee89e3a8662ea71afd2644e2197 100644 (file)
@@ -110,6 +110,7 @@ instance Alignable Term where
        withIndent  ind t = Term $ \ro -> unTerm t ro{reader_indent=ind}
        incrIndent  ind t = Term $ \ro -> unTerm t ro{reader_indent=reader_indent ro + ind}
        column f = Term $ \ro st -> unTerm (f st) ro st
+       indent f = Term $ \ro -> unTerm (f (reader_indent ro)) ro
        newlineWithoutIndent = Term $ \_ro _st ok _ko ->
                ok 0 $ TLB.singleton '\n'
        newlineWithIndent = Term $ \ro _st ok _ko ->
index 848941cd2264ef0a38f7340ea8a8c5b6258f4165..e881dd5f79414ca5ce2cc7958b665a02bb6d1a9b 100644 (file)
@@ -125,6 +125,7 @@ instance Alignable Dimension where
        withIndent  ind p = Dimension $ \ro -> unDimension p ro{reader_indent=ind}
        incrIndent  ind p = Dimension $ \ro -> unDimension p ro{reader_indent=reader_indent ro + ind}
        column f = Dimension $ \ro st -> unDimension (f st) ro st
+       indent f = Dimension $ \ro -> unDimension (f (reader_indent ro)) ro
        newlineWithoutIndent = Dimension $ \_ro _st ok _ko ->
                ok 0 Dim
                 { dim_width       = 0
index f0e25a135c7321521cf9ecd2b1bffd808b74b57c..ce8120ab6ecaa4ffc677c8be47e2f24696bf81d3 100644 (file)
@@ -109,6 +109,7 @@ instance Alignable TermIO where
        withIndent  ind p = TermIO $ \ro -> unTermIO p ro{reader_indent=ind}
        incrIndent  ind p = TermIO $ \ro -> unTermIO p ro{reader_indent=reader_indent ro + ind}
        column f = TermIO $ \ro st -> unTermIO (f st) ro st
+       indent f = TermIO $ \ro -> unTermIO (f (reader_indent ro)) ro
        newlineWithoutIndent = TermIO $ \ro _st ok _ko ->
                ok 0 $ IO.hPutChar (reader_handle ro) '\n'
        newlineWithIndent = TermIO $ \ro@Reader{reader_handle=h} _st ok _ko ->
index 765efaac428f4e65426c150837d3a4147241026e..e364ab83612b5627b51ea037cf6784509dde1044 100644 (file)
@@ -213,7 +213,7 @@ docPathMod (p::PathMod) =
        (\(NameMod n) -> Doc.textH n) <$> p
 
 docParen :: Doc.Textable d => d -> d
-docParen = Doc.between "(" ")"
+docParen = Doc.between (Doc.charH '(') (Doc.charH ')')
 
 {-
 docModules ::