diff options
author | stuebinm | 2021-09-16 02:27:26 +0200 |
---|---|---|
committer | stuebinm | 2021-09-16 02:27:26 +0200 |
commit | 35566bf15f43c355bdc72d62841a850a90c8ba03 (patch) | |
tree | 98ea0739e5aed68b6beff18edb23cf6c325283e5 /lib/Util.hs | |
parent | a27f5e365b83d88b230eb66b7032649bdb372546 (diff) |
moving lots of code around
(also renaming things now that concepts seem a bit clearer)
Diffstat (limited to 'lib/Util.hs')
-rw-r--r-- | lib/Util.hs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/Util.hs b/lib/Util.hs new file mode 100644 index 0000000..be67143 --- /dev/null +++ b/lib/Util.hs @@ -0,0 +1,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 <> "\"" |