Regex +regex-base

class RegexLike regex source => RegexContext regex source target
regex-base Text.Regex.Base.RegexLike
RegexContext is the polymorphic interface to do matching. Since target is polymorphic you may need to suply the type explicitly in contexts The monadic matchM version uses fail to report when the regex has no match in source. Two examples: Here the contest Bool is inferred: > [ c | let notVowel = makeRegex "[^aeiou]" :: Regex, c <- ['a'..'z'], match notVowel [c] ] > > "bcdfghjklmnpqrstvwxyz" Here the context '[String]' must be supplied: > let notVowel = (makeRegex "[^aeiou]" :: Regex ) > in do { c <- ['a'..'z'] ; matchM notVowel [c] } :: [String] > > ["b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","y","z"]
class Extract source => RegexLike regex source
regex-base Text.Regex.Base.RegexLike
RegexLike is parametrized on a regular expression type and a source type to run the matching on. There are default implementations: matchTest and matchOnceText use matchOnce; matchCount and matchAllText use matchAll. matchOnce uses matchOnceText and matchAll uses matchAllText. So a minimal complete instance need to provide at least (matchOnce or matchOnceText) and (matchAll or matchAllText). Additional definitions are often provided > [ c | let notVowel = makeRegex "[^aeiou]" :: Regex, c <- ['a'..'z'], matchTest notVowel [c] ] > > "bcdfghjklmnpqrstvwxyz" The strictness of these functions is instance dependent.
class RegexOptions regex compOpt execOpt => RegexMaker regex compOpt execOpt source | regex -> compOpt execOpt, compOpt -> regex execOpt, execOpt -> regex compOpt
regex-base Text.Regex.Base.RegexLike
RegexMaker captures the creation of the compiled regular expression from a source type and an option type. makeRegexM and makeRegexM report parse error using MonadError, usually (Either String regex). The makeRegex function has a default implementation that depends on makeRegexOpts and used defaultCompOpt and defaultExecOpt. Similarly for makeRegexM and makeRegexOptsM. There are also default implementaions for makeRegexOpts and makeRegexOptsM in terms of each other. So a minimal instance definition needs to only define one of these, hopefully makeRegexOptsM.
class RegexOptions regex compOpt execOpt | regex -> compOpt execOpt, compOpt -> regex execOpt, execOpt -> regex compOpt
regex-base Text.Regex.Base.RegexLike
Rather than carry them around spearately, the options for how to execute a regex are kept as part of the regex. There are two types of options. Those that can only be specified at compilation time and never changed are CompOpt. Those that can be changed later and affect how matching is performed are ExecOpt. The actually types for these depend on the backend.
module Text.Regex.Base.RegexLike
regex-base Text.Regex.Base.RegexLike
Classes and instances for Regex matching. All the classes are declared here, and some common type aliases, and the MatchResult data type. The only instances here are for Extract String and Extract ByteString. There are no data values. The RegexContext instances are in Text.Regex.Base.Context, except for ones which run afoul of a repeated variable (RegexContext regex a a), which are defined in each modules' String and ByteString modules.
getVersion_Text_Regex_Base :: Version
regex-base Text.Regex.Base
makeRegex :: RegexMaker regex compOpt execOpt source => source -> regex
regex-base Text.Regex.Base.RegexLike
makeRegexM :: (RegexMaker regex compOpt execOpt source, Monad m) => source -> m regex
regex-base Text.Regex.Base.RegexLike
makeRegexOpts :: RegexMaker regex compOpt execOpt source => compOpt -> execOpt -> source -> regex
regex-base Text.Regex.Base.RegexLike
makeRegexOptsM :: (RegexMaker regex compOpt execOpt source, Monad m) => compOpt -> execOpt -> source -> m regex
regex-base Text.Regex.Base.RegexLike