summaryrefslogtreecommitdiff
path: root/lib/Util.hs
diff options
context:
space:
mode:
authorstuebinm2021-09-19 22:39:01 +0200
committerstuebinm2021-09-19 22:39:01 +0200
commit70d37dcb8b381ba1b0b0d1f97d2fe99522f387a6 (patch)
tree308c284dbafbabda854f3ac941d584493ae692e6 /lib/Util.hs
parentccb57f9a16b47aab55f786b976b0b8e89ff49f36 (diff)
support for properties that aren't strings
apparently i couldn't read or something?
Diffstat (limited to 'lib/Util.hs')
-rw-r--r--lib/Util.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Util.hs b/lib/Util.hs
index 42ba960..82d326f 100644
--- a/lib/Util.hs
+++ b/lib/Util.hs
@@ -9,6 +9,7 @@ module Util where
import Data.Aeson as Aeson
import Data.Text (Text)
import qualified Data.Text as T
+import Tiled2 (PropertyValue(..))
-- | haskell's many string types are FUN …
showText :: Show a => a -> Text
@@ -29,6 +30,11 @@ instance PrettyPrint Aeson.Value where
Aeson.String s -> prettyprint s
v -> (T.pack . show) v
+instance PrettyPrint PropertyValue where
+ prettyprint = \case
+ StrProp str -> str
+ BoolProp bool -> if bool then "true" else "false"
+
-- | here since Unit is sometimes used as dummy type
instance PrettyPrint () where
prettyprint _ = error "shouldn't pretty-print Unit"