I created a Dhall library dhall-text-utils containing utilities for validation and modification of Text
values.
For example:
let TU = https://raw.githubusercontent.com/kukimik/dhall-text-utils/v0.1.0/src/package.dhall
let L = TU.Logic
let P = TU.Predicates
let T = TU.Transformations
let f : Text -> Text =
\(t : Text) ->
L.ifThenElse
(L.and [L.not (P.isEmpty t)
,P.isASCII t
,P.contains "ab" t])
"the text is non-empty, contains only ASCII characters and contains \"ab\" as a substring"
"the text is either empty, contains non-ASCII characters or does not contain \"ab\" as a substring"
in [f "abc"
,f ""
,f "abć"
,f "acb"
,T.stripPrefix "abc" "abcdef"]
evaluates to
[ "the text is non-empty, contains only ASCII characters and contains \"ab\" as a substring"
, "the text is either empty, contains non-ASCII characters or does not contain \"ab\" as a substring"
, "the text is either empty, contains non-ASCII characters or does not contain \"ab\" as a substring"
, "the text is either empty, contains non-ASCII characters or does not contain \"ab\" as a substring"
, "def"
]
Comments are most welcome.