summaryrefslogtreecommitdiff
path: root/src/Test.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Test.hs')
-rw-r--r--src/Test.hs53
1 files changed, 1 insertions, 52 deletions
diff --git a/src/Test.hs b/src/Test.hs
index 3808186..435250e 100644
--- a/src/Test.hs
+++ b/src/Test.hs
@@ -18,9 +18,6 @@ module Test (
someConstValue, fromConstValue,
fromSomeVarValue, textSomeVarValue, someVarValueType,
- RecordSelector(..),
- ExprListUnpacker(..),
- ExprEnumerator(..),
Expr(..), varExpr, mapExpr, eval, evalSome, evalSomeWith,
Traced(..), EvalTrace, VarNameSelectors, gatherVars,
AppAnnotation(..),
@@ -45,13 +42,13 @@ import Data.String
import Data.Text (Text)
import Data.Text qualified as T
import Data.Typeable
-import Data.Void
import Text.Regex.TDFA qualified as RE
import Text.Regex.TDFA.Text qualified as RE
import {-# SOURCE #-} Network
import {-# SOURCE #-} Process
+import Script.Expr.Class
import Util
data Module = Module
@@ -159,52 +156,10 @@ isInternalVar (LocalVarName (VarName name))
| otherwise = False
-class Typeable a => ExprType a where
- textExprType :: proxy a -> Text
- textExprValue :: a -> Text
-
- recordMembers :: [(Text, RecordSelector a)]
- recordMembers = []
-
- exprListUnpacker :: proxy a -> Maybe (ExprListUnpacker a)
- exprListUnpacker _ = Nothing
-
- exprEnumerator :: proxy a -> Maybe (ExprEnumerator a)
- exprEnumerator _ = Nothing
-
-instance ExprType Integer where
- textExprType _ = T.pack "integer"
- textExprValue x = T.pack (show x)
-
- exprEnumerator _ = Just $ ExprEnumerator enumFromTo enumFromThenTo
-
-instance ExprType Scientific where
- textExprType _ = T.pack "number"
- textExprValue x = T.pack (show x)
-
-instance ExprType Bool where
- textExprType _ = T.pack "bool"
- textExprValue True = T.pack "true"
- textExprValue False = T.pack "false"
-
-instance ExprType Text where
- textExprType _ = T.pack "string"
- textExprValue x = T.pack (show x)
-
instance ExprType Regex where
textExprType _ = T.pack "regex"
textExprValue _ = T.pack "<regex>"
-instance ExprType Void where
- textExprType _ = T.pack "void"
- textExprValue _ = T.pack "<void>"
-
-instance ExprType a => ExprType [a] where
- textExprType _ = "[" <> textExprType @a Proxy <> "]"
- textExprValue x = "[" <> T.intercalate ", " (map textExprValue x) <> "]"
-
- exprListUnpacker _ = Just $ ExprListUnpacker id (const Proxy)
-
instance ExprType TestBlock where
textExprType _ = "test block"
textExprValue _ = "<test block>"
@@ -327,12 +282,6 @@ someVarValueType (SomeVarValue (VarValue _ args _ :: VarValue a))
| otherwise = ExprTypeFunction args (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])
-
data Expr a where
Let :: forall a b. ExprType b => SourceLine -> TypedVarName b -> Expr b -> Expr a -> Expr a