-- | Write something to the output builder.
build :: Write -> PP ()
build x = do
  ps <- get
  case x of
    WriteNewline ->
      let !column = 0
          !line = psLine ps + 1
      in put ps { psBuilder = psBuilder ps <> fromLazyText "\n"
                , psColumn = column
                , psLine = line
                }
    WriteText text ->
      let !column = psColumn ps + fromIntegral (T.length text)
          !builder = psBuilder ps <> fromLazyText text
      in put ps { psBuilder = builder
                , psColumn = column
                }

-- | Write some text to the builder. Shouldn't contain newlines.
build :: Write -> PP ()
build x = do
  ps <- get
  case x of
    WriteNewline ->
      let !column = 0
          !line = psLine ps + 1
      in put ps { psBuilder = psBuilder ps <> fromLazyText "\n"
                , psColumn = column
                , psLine = line
                }
    WriteText text ->
      let !column = psColumn ps + fromIntegral (T.length text)
          !builder = psBuilder ps <> fromLazyText text
      in put ps { psBuilder = builder
                , psColumn = column
                }

-- | Write some text to the builder. Shouldn't contain newlines.
build x = do
  ps <- get
  case x of
    WriteNewline ->
      let !column = 0
          !line = psLine ps + 1
      in put ps { psBuilder = psBuilder ps <> fromLazyText "\n"
                , psColumn = column
                , psLine = line
                }
    WriteText text ->
      let !column = psColumn ps + fromIntegral (T.length text)
          !builder = psBuilder ps <> fromLazyText text
      in put ps { psBuilder = builder
                , psColumn = column
                }

-- | Write some text to the builder. Shouldn't contain newlines.