summaryrefslogtreecommitdiff
path: root/src/Script
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2025-09-21 22:49:21 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2025-09-21 22:49:21 +0200
commitc558b300a3353edf7c88a2c363cb6bc7b7c1dcb7 (patch)
treef8a21828219592a2a23289be74c7faaa95f8e3d0 /src/Script
parent442bc3df9692edde632e3a1d7217e861bf85fd81 (diff)
Require result of TestBlock to be ExprType instanceHEADmaster
Diffstat (limited to 'src/Script')
-rw-r--r--src/Script/Expr/Class.hs4
-rw-r--r--src/Script/Object.hs11
2 files changed, 15 insertions, 0 deletions
diff --git a/src/Script/Expr/Class.hs b/src/Script/Expr/Class.hs
index 20a92b4..005b6a8 100644
--- a/src/Script/Expr/Class.hs
+++ b/src/Script/Expr/Class.hs
@@ -39,6 +39,10 @@ data ExprListUnpacker a = forall e. ExprType e => ExprListUnpacker (a -> [e]) (P
data ExprEnumerator a = ExprEnumerator (a -> a -> [a]) (a -> a -> a -> [a])
+instance ExprType () where
+ textExprType _ = "Unit"
+ textExprValue () = "()"
+
instance ExprType Integer where
textExprType _ = T.pack "integer"
textExprValue x = T.pack (show x)
diff --git a/src/Script/Object.hs b/src/Script/Object.hs
index 9232b21..7e60f80 100644
--- a/src/Script/Object.hs
+++ b/src/Script/Object.hs
@@ -7,8 +7,11 @@ module Script.Object (
) where
import Data.Kind
+import Data.Text (Text)
import Data.Typeable
+import Script.Expr.Class
+
newtype ObjectId = ObjectId Int
@@ -16,9 +19,17 @@ class Typeable a => ObjectType m a where
type ConstructorArgs a :: Type
type ConstructorArgs a = ()
+ textObjectType :: proxy (m a) -> proxy a -> Text
+ textObjectValue :: proxy (m a) -> a -> Text
+
createObject :: ObjectId -> ConstructorArgs a -> m (Object m a)
destroyObject :: Object m a -> m ()
+instance (Typeable m, ObjectType m a) => ExprType (Object m a) where
+ textExprType _ = textObjectType (Proxy @(m a)) (Proxy @a)
+ textExprValue = textObjectValue (Proxy @(m a)) . objImpl
+
+
data Object m a = ObjectType m a => Object
{ objId :: ObjectId
, objImpl :: a