A little more infrastructure
Getty Ritter
9 years ago
1 | {-# LANGUAGE RecordWildCards #-} | |
2 | {-# LANGUAGE OverloadedStrings #-} | |
3 | ||
1 | 4 | module Data.SCargot.Pretty where |
2 | 5 | |
3 | 6 | |
48 | 51 | , maxWidth :: Maybe Int -- ^ The maximum width (if any) |
49 | 52 | } |
50 | 53 | |
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 | ||
51 | 62 | 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 | |
56 | 68 | } |
57 | 69 | |
58 | 70 | prettyPrintSExpr :: LayoutOptions a -> SExpr a -> Text |
71 | prettyPrintSExpr LayoutOptions { .. } = go 0 | |
72 | where go _ SNil = "()" | |
73 | go _ _ = undefined |