From dc2202f36f8ee220293cc6f230be604a19be8cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Wed, 7 Aug 2024 20:59:18 +0200 Subject: Replace first command (wait) with a builtin --- src/Test.hs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/Test.hs') diff --git a/src/Test.hs b/src/Test.hs index a54bbbd..e2f829b 100644 --- a/src/Test.hs +++ b/src/Test.hs @@ -7,8 +7,8 @@ module Test ( MonadEval(..), VarName(..), TypedVarName(..), textVarName, unpackVarName, - ExprType(..), - SomeVarValue(..), fromSomeVarValue, textSomeVarValue, + ExprType(..), SomeExpr(..), SomeExprType(..), someExprType, + SomeVarValue(..), fromSomeVarValue, textSomeVarValue, someVarValueType, RecordSelector(..), ExprListUnpacker(..), ExprEnumerator(..), @@ -135,9 +135,16 @@ instance ExprType TestBlock where textExprValue _ = "" emptyVarValue = TestBlock [] -data SomeVarValue = forall a. ExprType a => SomeVarValue a -data RecordSelector a = forall b. ExprType b => RecordSelector (a -> b) +data SomeExpr = forall a. ExprType a => SomeExpr (Expr a) + +data SomeExprType = forall a. ExprType a => SomeExprType (Proxy a) + +someExprType :: SomeExpr -> SomeExprType +someExprType (SomeExpr (_ :: Expr a)) = SomeExprType (Proxy @a) + + +data SomeVarValue = forall a. ExprType a => SomeVarValue a fromSomeVarValue :: forall a m. (ExprType a, MonadFail m) => VarName -> SomeVarValue -> m a fromSomeVarValue name (SomeVarValue value) = maybe (fail err) return $ cast value @@ -146,6 +153,12 @@ fromSomeVarValue name (SomeVarValue value) = maybe (fail err) return $ cast valu textSomeVarValue :: SomeVarValue -> Text textSomeVarValue (SomeVarValue value) = textExprValue value +someVarValueType :: SomeVarValue -> SomeExprType +someVarValueType (SomeVarValue (_ :: a)) = SomeExprType (Proxy @a) + + +data RecordSelector a = forall b. ExprType b => RecordSelector (a -> b) + data ExprListUnpacker a = forall e. ExprType e => ExprListUnpacker (a -> [e]) (Proxy a -> Proxy e) data ExprEnumerator a = ExprEnumerator (a -> a -> [a]) (a -> a -> a -> [a]) -- cgit v1.2.3