diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2024-08-07 20:59:18 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2024-08-07 21:51:10 +0200 |
commit | dc2202f36f8ee220293cc6f230be604a19be8cbb (patch) | |
tree | 5201a7751ad655460d48d5e6456f8546179c25b5 /src/Test.hs | |
parent | 18ced99f826746a19aa6c0b351673d132f86421a (diff) |
Replace first command (wait) with a builtin
Diffstat (limited to 'src/Test.hs')
-rw-r--r-- | src/Test.hs | 21 |
1 files changed, 17 insertions, 4 deletions
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 _ = "<test block>" 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]) |