From d41cc2a1cdf9fc7a9d5781779363b9bb3eb82c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 25 Apr 2026 13:46:40 +0200 Subject: Concat builtin function Changelog: Added `concat` function for lists --- src/Test/Builtins.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/Test') 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 -- cgit v1.2.3