packages feed

hydra-kernel-0.18.1: hydra-kernel-json/hydra/core/lib/regex.json

{
  "name": "hydra.core.lib.regex",
  "metadata": {
    "description": "Primitives in the hydra.core.lib.regex module.",
    "comments": [
      "Pattern syntax and semantics are Hydra-defined and translingual: they are specified once, in Hydra's regular-expression specification, and the same pattern means the same thing on every host.",
      "Matching is leftmost-longest: a match begins at the earliest possible position in the string, and among the matches beginning at that position the longest is chosen.",
      "findAll, replaceAll, and split operate on non-overlapping matches, found left to right."],
    "seeAlso": [],
    "provisions": []},
  "dependencies": [{"module": "hydra.core.model"}, {"module": "hydra.core.packaging"}, {"module": "hydra.core.typing"}],
  "definitions": [
    {
      "primitive": {
        "name": "hydra.core.lib.regex.find",
        "metadata": {
          "description": "Find the first regex match within a string, returning the matched substring if any.",
          "comments": [
            "find(pat, s) returns Just(t) where t is the leftmost-longest substring of s matching pat, or Nothing if pat does not match anywhere in s.",
            "Pattern syntax and semantics are Hydra-defined and translingual; see docs/specification/regex.md.",
            "Total; a pattern that does not parse under the Hydra regex grammar is treated as not matching anywhere, the same as a well-formed pattern with no match."],
          "seeAlso": [],
          "lifecycle": {"availableSince": "0.15"},
          "provisions": [
            {
              "name": "hydra.core.lib.regex.find.returnsLeftmostLongestMatch",
              "kind": "requirement",
              "statement": "find returns the leftmost-longest substring matching the pattern, wrapped, when the pattern matches anywhere in the string, including alternation where the longer branch wins and greedy quantifiers that pick the longest run."},
            {
              "name": "hydra.core.lib.regex.find.noneWhenNoMatch",
              "kind": "requirement",
              "statement": "find returns none when the pattern does not match anywhere in the string, including on the empty string, and when the pattern is ill-formed under the Hydra regex grammar (treated the same as a well-formed pattern with no match, never a host-specific parse error)."}]},
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "pat", "description": "the regex pattern to search for", "type": {"literal": "string"}, "isLazy": false},
            {"name": "s", "description": "the string to search within", "type": {"literal": "string"}, "isLazy": false}],
          "result": {"type": {"optional": {"literal": "string"}}}},
        "isPure": true,
        "isTotal": true}},
    {
      "primitive": {
        "name": "hydra.core.lib.regex.findAll",
        "metadata": {
          "description": "Find all non-overlapping regex matches within a string.",
          "comments": [
            "findAll(pat, s) returns the list of all leftmost-longest, non-overlapping matches of pat in s, in the order they appear. Returns the empty list if pat does not match anywhere.",
            "Pattern syntax and semantics are Hydra-defined and translingual; see docs/specification/regex.md.",
            "Total; an unparseable pattern yields the empty list, the same as a well-formed pattern with no matches."],
          "seeAlso": [],
          "lifecycle": {"availableSince": "0.15"},
          "provisions": [
            {
              "name": "hydra.core.lib.regex.findAll.returnsAllNonOverlappingMatchesInOrder",
              "kind": "requirement",
              "statement": "findAll returns every leftmost-longest, non-overlapping match of the pattern in the string, in the order they appear."},
            {
              "name": "hydra.core.lib.regex.findAll.emptyListWhenNoMatch",
              "kind": "requirement",
              "statement": "findAll returns the empty list when the pattern does not match anywhere, including when the pattern is ill-formed under the Hydra regex grammar (treated the same as a well-formed pattern with no matches)."}]},
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "pat", "description": "the regex pattern to search for", "type": {"literal": "string"}, "isLazy": false},
            {"name": "s", "description": "the string to search within", "type": {"literal": "string"}, "isLazy": false}],
          "result": {"type": {"list": {"literal": "string"}}}},
        "isPure": true,
        "isTotal": true}},
    {
      "primitive": {
        "name": "hydra.core.lib.regex.matches",
        "metadata": {
          "description": "Test whether a regex matches an entire string.",
          "comments": [
            "matches(pat, s) returns true iff pat matches the whole of s (anchored at both ends; a match of a proper substring of s does not suffice). To test whether pat matches anywhere within s, use find.",
            "Pattern syntax and semantics are Hydra-defined and translingual; see docs/specification/regex.md.",
            "Total; an unparseable pattern yields false, the same as a well-formed pattern with no match."],
          "seeAlso": [],
          "lifecycle": {"availableSince": "0.15"},
          "provisions": [
            {
              "name": "hydra.core.lib.regex.matches.isWholeStringAnchored",
              "kind": "requirement",
              "statement": "matches is always anchored to the whole string at both ends, regardless of explicit ^/$ in the pattern: a match of a proper substring does not suffice, and ^/$ never match at an internal line break (string-boundary anchors, not line-boundary)."},
            {
              "name": "hydra.core.lib.regex.matches.testsMinimalCoreGrammar",
              "kind": "requirement",
              "statement": "matches correctly evaluates every construct in the minimal-core regex grammar: literals, character classes (including negation and ranges), the wildcard (matching any character including newline), quantifiers (?, *, +, {n}, {n,}, {n,m}), alternation (leftmost-longest preference, not leftmost-first), and non-capturing grouping (including nested and quantified groups)."},
            {
              "name": "hydra.core.lib.regex.matches.treatsEscapedMetacharactersAsLiterals",
              "kind": "requirement",
              "statement": "matches treats a backslash-escaped metacharacter as the literal character, both at top level and inside a character class, and treats an unescaped dash as a literal at top level (never forming a range outside a class) while forming a range only inside a class."},
            {
              "name": "hydra.core.lib.regex.matches.falseWhenNoMatchOrIllFormed",
              "kind": "requirement",
              "statement": "matches returns false when the pattern does not match the whole string, including when the pattern is ill-formed under the Hydra regex grammar (treated the same as a well-formed pattern with no match, never a host-specific parse error) and for constructs outside the minimal core (such as the {,m} quantifier form)."}]},
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "pat", "description": "the regex pattern to test", "type": {"literal": "string"}, "isLazy": false},
            {"name": "s", "description": "the string to test against", "type": {"literal": "string"}, "isLazy": false}],
          "result": {"type": {"literal": "boolean"}}},
        "isPure": true,
        "isTotal": true}},
    {
      "primitive": {
        "name": "hydra.core.lib.regex.replace",
        "metadata": {
          "description": "Replace the first regex match in a string with a replacement string.",
          "comments": [
            "replace(pat, repl, s) returns s with the first leftmost-longest match of pat replaced by repl. If pat does not match, s is returned unchanged.",
            "Replacement-string syntax (capture-group references such as $1 or \\\\1, literal escapes) is host-defined.",
            "Pattern syntax and semantics are Hydra-defined and translingual; see docs/specification/regex.md.",
            "Total; an unparseable pattern leaves s unchanged, the same as a well-formed pattern with no match."],
          "seeAlso": [],
          "lifecycle": {"availableSince": "0.15"},
          "provisions": [
            {
              "name": "hydra.core.lib.regex.replace.replacesLeftmostLongestMatch",
              "kind": "requirement",
              "statement": "replace replaces the first (leftmost-longest) match of the pattern with the replacement string, including an anchored match at the start of the string."},
            {
              "name": "hydra.core.lib.regex.replace.unchangedWhenNoMatch",
              "kind": "requirement",
              "statement": "replace returns the string unchanged when the pattern does not match anywhere, including when the pattern is ill-formed under the Hydra regex grammar (treated the same as a well-formed pattern with no match)."}]},
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "pat", "description": "the regex pattern to match", "type": {"literal": "string"}, "isLazy": false},
            {"name": "repl", "description": "the replacement string", "type": {"literal": "string"}, "isLazy": false},
            {"name": "s", "description": "the string to operate on", "type": {"literal": "string"}, "isLazy": false}],
          "result": {"type": {"literal": "string"}}},
        "isPure": true,
        "isTotal": true}},
    {
      "primitive": {
        "name": "hydra.core.lib.regex.replaceAll",
        "metadata": {
          "description": "Replace all non-overlapping regex matches in a string with a replacement string.",
          "comments": [
            "replaceAll(pat, repl, s) returns s with every leftmost-longest, non-overlapping match of pat replaced by repl. If pat does not match anywhere, s is returned unchanged.",
            "Replacement-string syntax is host-defined; see replace for the caveat.",
            "Pattern syntax and semantics are Hydra-defined and translingual; see docs/specification/regex.md.",
            "Total; an unparseable pattern leaves s unchanged, the same as a well-formed pattern with no match."],
          "seeAlso": [],
          "lifecycle": {"availableSince": "0.15"},
          "provisions": [
            {
              "name": "hydra.core.lib.regex.replaceAll.replacesEveryNonOverlappingMatch",
              "kind": "requirement",
              "statement": "replaceAll replaces every leftmost-longest, non-overlapping match of the pattern with the replacement string, including when the replacement string is empty."},
            {
              "name": "hydra.core.lib.regex.replaceAll.unchangedWhenNoMatch",
              "kind": "requirement",
              "statement": "replaceAll returns the string unchanged when the pattern does not match anywhere, including when the pattern is ill-formed under the Hydra regex grammar (treated the same as a well-formed pattern with no match)."}]},
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "pat", "description": "the regex pattern to match", "type": {"literal": "string"}, "isLazy": false},
            {"name": "repl", "description": "the replacement string", "type": {"literal": "string"}, "isLazy": false},
            {"name": "s", "description": "the string to operate on", "type": {"literal": "string"}, "isLazy": false}],
          "result": {"type": {"literal": "string"}}},
        "isPure": true,
        "isTotal": true}},
    {
      "primitive": {
        "name": "hydra.core.lib.regex.split",
        "metadata": {
          "description": "Split a string by occurrences of a regex pattern.",
          "comments": [
            "split(pat, s) returns the list of substrings of s obtained by splitting on every leftmost-longest, non-overlapping match of pat.",
            "Trailing empty splits are host-defined (some engines retain them, some discard them; for portable code, do not rely on the trailing-empty behavior).",
            "Pattern syntax and semantics are Hydra-defined and translingual; see docs/specification/regex.md.",
            "Total; an unparseable pattern yields the single-element list containing s, the same as a well-formed pattern with no match."],
          "seeAlso": [],
          "lifecycle": {"availableSince": "0.15"},
          "provisions": [
            {
              "name": "hydra.core.lib.regex.split.splitsOnEveryNonOverlappingMatch",
              "kind": "requirement",
              "statement": "split returns the substrings of the string obtained by splitting on every leftmost-longest, non-overlapping match of the pattern, including splitting on a fixed delimiter, on a character class, and splitting into a trailing empty substring when the pattern matches at the end of the string."},
            {
              "name": "hydra.core.lib.regex.split.singleElementListWhenNoMatchOrIllFormed",
              "kind": "requirement",
              "statement": "split returns the single-element list containing the original string unchanged when the pattern does not match anywhere, including when the pattern is ill-formed under the Hydra regex grammar (treated the same as a well-formed pattern with no match)."}]},
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "pat", "description": "the regex pattern to split on", "type": {"literal": "string"}, "isLazy": false},
            {"name": "s", "description": "the string to split", "type": {"literal": "string"}, "isLazy": false}],
          "result": {"type": {"list": {"literal": "string"}}}},
        "isPure": true,
        "isTotal": true}}]}