-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathCommon.hs
35 lines (26 loc) · 820 Bytes
/
Common.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{-# LANGUAGE OverloadedStrings #-}
module Elm.Common where
import Text.PrettyPrint.Leijen.Text hiding ((<$>), (<>))
import Data.Monoid
import Data.Text (Text)
import qualified Data.Text.Lazy as LT
import Formatting hiding (text)
data Options = Options
{ fieldLabelModifier :: Text -> Text
}
defaultOptions :: Options
defaultOptions = Options {fieldLabelModifier = id}
cr :: Format r r
cr = now "\n"
mintercalate
:: Monoid m
=> m -> [m] -> m
mintercalate _ [] = mempty
mintercalate _ [x] = x
mintercalate seperator (x:xs) = x <> seperator <> mintercalate seperator xs
pprinter :: Doc -> Text
pprinter = LT.toStrict . displayT . renderPretty 0.4 100
stext :: Data.Text.Text -> Doc
stext = text . LT.fromStrict
spaceparens :: Doc -> Doc
spaceparens doc = "(" <+> doc <+> ")"