gdritter repos s-cargot / fda0b87
A little more infrastructure Getty Ritter 9 years ago
1 changed file(s) with 19 addition(s) and 4 deletion(s). Collapse all Expand all
1 {-# LANGUAGE RecordWildCards #-}
2 {-# LANGUAGE OverloadedStrings #-}
3
14 module Data.SCargot.Pretty where
25
36
4851 , maxWidth :: Maybe Int -- ^ The maximum width (if any)
4952 }
5053
54 flatPrint :: (a -> Text) -> LayoutOptions a
55 flatPrint printer = LayoutOptions
56 { atomPrinter = printer
57 , swingIndent = const True
58 , indentAmount = 2
59 , maxWidth = Nothing
60 }
61
5162 basicPrint :: (a -> Text) -> LayoutOptions a
52 basicPrint f = LayoutOptions
53 { atomPrinter = f
54 , swingIndent = const False
55 , maxWidth = Nothing
63 basicPrint printer = LayoutOptions
64 { atomPrinter = printer
65 , swingIndent = const True
66 , indentAmount = 2
67 , maxWidth = Just 80
5668 }
5769
5870 prettyPrintSExpr :: LayoutOptions a -> SExpr a -> Text
71 prettyPrintSExpr LayoutOptions { .. } = go 0
72 where go _ SNil = "()"
73 go _ _ = undefined