diff options
author | stuebinm | 2022-02-18 18:09:23 +0100 |
---|---|---|
committer | stuebinm | 2022-02-18 18:09:23 +0100 |
commit | 7c49e6c367c9d021f3630c08a4a13ba9abc5df08 (patch) | |
tree | c278d23a6e39c353f5aa02d1ce9785122e1eea62 /lib/Util.hs | |
parent | faa244e1a7e760be88054a5f15b3e115ad8e32e5 (diff) |
switch to universum prelude
also don't keep adjusted maps around if not necessary
Diffstat (limited to 'lib/Util.hs')
-rw-r--r-- | lib/Util.hs | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/Util.hs b/lib/Util.hs index 21a2661..f935e78 100644 --- a/lib/Util.hs +++ b/lib/Util.hs @@ -6,30 +6,23 @@ -- concerns itself with wrangling haskell's string types module Util ( mkProxy - , showText , PrettyPrint(..) , printPretty , naiveEscapeHTML , layerIsEmpty ) where +import Universum + import Data.Aeson as Aeson -import Data.Proxy (Proxy (..)) -import Data.Set (Set) import qualified Data.Set as S -import Data.Text (Text) import qualified Data.Text as T import Tiled (Layer (layerData), PropertyValue (..), Tileset (tilesetName), layerName, mkTiledId) --- | helper function to create proxies mkProxy :: a -> Proxy a mkProxy = const Proxy --- | haskell's many string types are FUN … -showText :: Show a => a -> Text -showText = T.pack . show - -- | a class to address all the string conversions necessary -- when using Show to much that just uses Text instead class PrettyPrint a where @@ -43,7 +36,7 @@ instance PrettyPrint Text where instance PrettyPrint Aeson.Value where prettyprint = \case Aeson.String s -> prettyprint s - v -> (T.pack . show) v + v -> show v instance PrettyPrint t => PrettyPrint (Set t) where prettyprint = prettyprint . S.toList @@ -52,8 +45,8 @@ instance PrettyPrint PropertyValue where prettyprint = \case StrProp str -> str BoolProp bool -> if bool then "true" else "false" - IntProp int -> showText int - FloatProp float -> showText float + IntProp int -> show int + FloatProp float -> show float -- | here since Unit is sometimes used as dummy type instance PrettyPrint () where @@ -69,7 +62,7 @@ instance PrettyPrint a => PrettyPrint [a] where prettyprint = T.intercalate ", " . fmap prettyprint printPretty :: PrettyPrint a => a -> IO () -printPretty = putStr . T.unpack . prettyprint +printPretty = putStr . toString . prettyprint layerIsEmpty :: Layer -> Bool |