blob: be671436fc6bfb0239aec72604fd7d184a886e48 (
plain)
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
|
{-# LANGUAGE OverloadedStrings #-}
module Util where
import Data.Text (Text)
import Data.Text as T
import Data.Aeson as Aeson
-- | haskell's many string types are FUN …
showText :: Show a => a -> Text
showText = T.pack . show
-- | same as showText, but without the "String"-prefix for strings
-- TODO: serialise back into json for printing? People may get
-- confused by the type annotations if they only know json …
showAeson :: Aeson.Value -> Text
showAeson (Aeson.String s) = showText s
showAeson v = showText v
-- | adds quotes (but does not escape, for now!)
quote :: Text -> Text
quote text = "\"" <> text <> "\""
|