Text.Regex.Posix exposes too little
simonmar at microsoft.com
Mon Feb 14 07:08:04 EST 2005
On 11 February 2005 21:24, Peter Simons wrote:
> I was wondering why Text.Regex.Posix does not expose the Ptr
> interface to the regular expression library? Is there a
> deeper reason for that?
No deep reason that I'm aware of.
> I am also worried about the fact that the module uses
> finalizers to free-up unused expressions -- rather than
> providing a bracket-style
> withRegex :: String -> Int -> (Regex -> IO a) -> IO a
We quite often use it with a regex defined at the top-level:
r = mkRegex "..."
f x = case matchRegex r x of ...
Although in this case there is limited benefit from having the regex
garbage collected, since there can only be a bounded, probably small,
number of these in the program.
Providing withRegex seems like a good idea, though.
> Last but not least I see that the regex flags are
> represented as an 'Int'. I don't feel strongly about this,
> but IMHO a
> data RegexFlag = IgnoreCase
> | Newline
> | ...
> data type with an appropriate declaration for Enum would be
> nicer for this purpose.
> Unless there is violent opposition, I'd volunteer to make
> those changes, because as it happens I need them anyway. ;-)
Please go ahead, I'll review and commit your patch.
More information about the Libraries