{-# 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 <> "\""