diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2026-04-25 13:46:40 +0200 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2026-05-17 21:54:23 +0200 |
| commit | d41cc2a1cdf9fc7a9d5781779363b9bb3eb82c00 (patch) | |
| tree | e2c7555cbf2be5981b805c459861e5834d31b23f /src/Test | |
| parent | 0d2b55b41a8f38264fd510efd4c1306239c94d17 (diff) | |
Concat builtin function
Changelog: Added `concat` function for lists
Diffstat (limited to 'src/Test')
| -rw-r--r-- | src/Test/Builtins.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Test/Builtins.hs b/src/Test/Builtins.hs index 32483d1..85f7b86 100644 --- a/src/Test/Builtins.hs +++ b/src/Test/Builtins.hs @@ -6,6 +6,7 @@ import Data.Map qualified as M import Data.Proxy import Data.Scientific import Data.Text (Text) +import Data.Text qualified as T import Process import Process.Signal @@ -20,6 +21,7 @@ builtins = M.fromList $ concat , fq "guard" builtinGuard , fq "multiply_timeout" builtinMultiplyTimeout , fq "wait" builtinWait + , fq "concat" builtinConcat ] , map (uncurry fq) signalBuiltins ] @@ -73,3 +75,14 @@ builtinMultiplyTimeout = SomeExpr $ ArgsReq (biArgs $ [ ( Just "by", SomeArgumen builtinWait :: SomeExpr builtinWait = SomeExpr $ Pure $ TestBlockStep EmptyTestBlock Wait + +builtinConcat :: SomeExpr +builtinConcat = SomeExpr $ TypeLambda (TypeVar "a") + (ExprTypeFunction + (ExprTypeArguments $ FunctionArguments $ M.singleton Nothing $ SomeArgumentType RequiredArgument + (ExprTypeApp (ExprTypeConstr1 (Proxy @[])) [ ExprTypeApp (ExprTypeConstr1 (Proxy @[])) [ ExprTypeVar (TypeVar "a") ] ] )) + (ExprTypeApp (ExprTypeConstr1 (Proxy @[])) [ ExprTypeVar (TypeVar "a") ]) + ) $ \case + ExprTypePrim (pa :: Proxy a) -> HideFunType (FunctionArguments $ M.singleton Nothing $ SomeArgumentType RequiredArgument (ExprTypePrim (Proxy :: Proxy [[ a ]]))) $ + ArgsReq (biArgs [ ( Nothing, SomeArgumentType RequiredArgument (ExprTypePrim pa) ) ]) $ FunctionAbstraction $ (concat :: [[ a ]] -> [ a ]) <$> biVar "$0" + t -> Undefined ("ambiguous type ‘" <> T.unpack (textSomeExprType t) <> "’ for concat") :: Expr DynamicType |