summaryrefslogtreecommitdiff
path: root/src/Test.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Test.hs')
-rw-r--r--src/Test.hs21
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])