module Autolib.ToDoc.Oneline where

import Autolib.ToDoc.Class


oneline :: Doc -> Doc
oneline :: Doc -> Doc
oneline = String -> Doc
text (String -> Doc) -> (Doc -> String) -> Doc -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [String] -> String
unwords ([String] -> String) -> (Doc -> [String]) -> Doc -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String]
words (String -> [String]) -> (Doc -> String) -> Doc -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> String
render

newtype Oneline t = Oneline t

instance ToDoc t => ToDoc (Oneline t) where
  toDocPrec :: Int -> Oneline t -> Doc
toDocPrec Int
p (Oneline t
x) = Doc -> Doc
oneline (Doc -> Doc) -> Doc -> Doc
forall a b. (a -> b) -> a -> b
$ Int -> t -> Doc
forall a. ToDoc a => Int -> a -> Doc
toDocPrec Int
p t
x