diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2025-04-20 22:58:31 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-04-22 19:39:47 +0200 |
commit | 47ec9619f90af3264b11ad26654610a043ed0d8d (patch) | |
tree | 97f1f629ec11b06ceba3825dd8895292c9ea538d /src/Script/Expr.hs | |
parent | 57671619f81dbdcafa1fce4f91956bc647a57588 (diff) |
Conversions for variable expansion in ExprType class
Diffstat (limited to 'src/Script/Expr.hs')
-rw-r--r-- | src/Script/Expr.hs | 8 |
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 '$' |