From 47ec9619f90af3264b11ad26654610a043ed0d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 20 Apr 2025 22:58:31 +0200 Subject: Conversions for variable expansion in ExprType class --- src/Script/Expr.hs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/Script/Expr.hs') diff --git a/src/Script/Expr.hs b/src/Script/Expr.hs index e8f6993..0c401e2 100644 --- a/src/Script/Expr.hs +++ b/src/Script/Expr.hs @@ -34,6 +34,8 @@ import Data.Foldable import Data.List import Data.Map (Map) import Data.Map qualified as M +import Data.Maybe +import Data.Scientific import Data.String import Data.Text (Text) import Data.Text qualified as T @@ -425,6 +427,12 @@ instance ExprType Regex where textExprType _ = T.pack "regex" textExprValue _ = T.pack "" + exprExpansionConvFrom = listToMaybe $ catMaybes + [ cast (RegexString) + , cast (RegexString . T.pack . show @Integer) + , cast (RegexString . T.pack . show @Scientific) + ] + regexCompile :: Text -> Either String Regex regexCompile src = either Left (Right . RegexCompiled src) $ RE.compile RE.defaultCompOpt RE.defaultExecOpt $ T.singleton '^' <> src <> T.singleton '$' -- cgit v1.2.3