summaryrefslogtreecommitdiff
path: root/src/Script/Expr.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Script/Expr.hs')
-rw-r--r--src/Script/Expr.hs8
1 files changed, 8 insertions, 0 deletions
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 "<regex>"
+ 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 '$'