address overflow in Prettier,
move Pi constructor to before it is constructed
This commit is contained in:
@@ -33,10 +33,10 @@ group : Doc -> Doc
|
|||||||
group x = Alt (flatten x) x
|
group x = Alt (flatten x) x
|
||||||
|
|
||||||
-- TODO - we can accumulate snoc and cat all at once
|
-- TODO - we can accumulate snoc and cat all at once
|
||||||
layout : List Item -> String
|
layout : List Item -> SnocList String -> String
|
||||||
layout [] = ""
|
layout [] acc = fastConcat $ cast acc
|
||||||
layout (LINE k :: x) = "\n" ++ replicate k ' ' ++ layout x
|
layout (LINE k :: x) acc = layout x (acc :< "\n" :< replicate k ' ')
|
||||||
layout (TEXT str :: x) = str ++ layout x
|
layout (TEXT str :: x) acc = layout x (acc :< str)
|
||||||
|
|
||||||
||| Whether a documents first line fits.
|
||| Whether a documents first line fits.
|
||||||
fits : Nat -> List Item -> Bool
|
fits : Nat -> List Item -> Bool
|
||||||
@@ -73,7 +73,7 @@ interface Pretty a where
|
|||||||
|
|
||||||
export
|
export
|
||||||
render : Nat -> Doc -> String
|
render : Nat -> Doc -> String
|
||||||
render w x = layout (best w 0 x)
|
render w x = layout (best w 0 x) [<]
|
||||||
|
|
||||||
public export
|
public export
|
||||||
Semigroup Doc where x <+> y = Seq x (Seq (Text " ") y)
|
Semigroup Doc where x <+> y = Seq x (Seq (Text " ") y)
|
||||||
|
|||||||
@@ -41,11 +41,11 @@ dumpContext top = do
|
|||||||
writeSource : String -> M ()
|
writeSource : String -> M ()
|
||||||
writeSource fn = do
|
writeSource fn = do
|
||||||
docs <- compile
|
docs <- compile
|
||||||
let src = unlines $ ["#!/usr/bin/env node"]
|
let src = unlines $
|
||||||
|
[ "#!/usr/bin/env node"
|
||||||
|
, "const PiType = (h0, h1) => ({ tag: \"PiType\", h0, h1 })" ]
|
||||||
++ map (render 90) docs
|
++ map (render 90) docs
|
||||||
++ [ "const PiType = (h0, h1) => ({ tag: \"PiType\", h0, h1 })"
|
++ [ "main();" ]
|
||||||
, "main();"
|
|
||||||
]
|
|
||||||
Right _ <- writeFile fn src
|
Right _ <- writeFile fn src
|
||||||
| Left err => fail (show err)
|
| Left err => fail (show err)
|
||||||
Right _ <- chmodRaw fn 493 | Left err => fail (show err)
|
Right _ <- chmodRaw fn 493 | Left err => fail (show err)
|
||||||
|
|||||||
Reference in New Issue
Block a user