summaryrefslogtreecommitdiff
path: root/src/Script/Expr
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2025-09-28 20:38:18 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2025-09-28 20:38:18 +0200
commit57c27f313e9f28548aec19e58b1497b79d7d5335 (patch)
tree6c4eaa4e64be6b7e6eb46133df018ce44c0a2ad7 /src/Script/Expr
parentc55f3775c9ce7842021a6e90db0437dce41cbecb (diff)
Additional instances of ExprType used by parsed commands
Diffstat (limited to 'src/Script/Expr')
-rw-r--r--src/Script/Expr/Class.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Script/Expr/Class.hs b/src/Script/Expr/Class.hs
index 005b6a8..810b0c8 100644
--- a/src/Script/Expr/Class.hs
+++ b/src/Script/Expr/Class.hs
@@ -79,3 +79,13 @@ instance ExprType a => ExprType [a] where
textExprValue x = "[" <> T.intercalate ", " (map textExprValue x) <> "]"
exprListUnpacker _ = Just $ ExprListUnpacker id (const Proxy)
+
+instance ExprType a => ExprType (Maybe a) where
+ textExprType _ = textExprType @a Proxy <> "?"
+ textExprValue (Just x) = textExprValue x
+ textExprValue Nothing = "Nothing"
+
+instance (ExprType a, ExprType b) => ExprType (Either a b) where
+ textExprType _ = textExprType @a Proxy <> "|" <> textExprType @b Proxy
+ textExprValue (Left x) = "Left " <> textExprValue x
+ textExprValue (Right x) = "Right " <> textExprValue x