Ann: regex-base-0.91

Chris Kuklewicz haskell at list.mightyreason.com
Tue Mar 13 07:29:08 EDT 2007


I have updated the darcs repository and the hackage repository to have
regex-base-0.91

Changes:

  GHC uses late instance overlap detection, whereas Hugs demands no potential
overlap.  Thus Hugs rejected some of the polymorphic results for matching given
by RegexContext instances.

  The solution in version 0.91 of regex-base is to use newtypes.  To this end
there are 4 newtypes which are used to disambiguate some of the more complicated
return types of match/matchM/=~/=~~.  The new haddock documentation for
Text.Regex.Base.Context has more details and lists all the instances.

  The 4 newtypes are:

> newtype AllSubmatches f b = AllSubmatches {getAllSubmatches :: (f b)}
> newtype AllTextSubmatches f b = AllTextSubmatches {getAllTextSubmatches :: (f b)}
> newtype AllMatches f b = AllMatches {getAllMatches :: (f b)}
> newtype AllTextMatches f b = AllTextMatches {getAllTextMatches :: (f b) }

The 'f' parameters are containers types, such as [] or (Array Int).

The two *Submatches types report all the captured (i.e. parenthesized) groups of
the first match found.  The two *Matches types report on the all the
non-overlapping matches found.  This clarifies the desires of the programmer and
allows choice of either result to be made.

The two *Text* version have the type of the searched text included in the type
of the result 'b', unlike the other two types.  This avoids overlapping.

These newtypes are not used for all the instances, but only where they are
needed to either avoid overlapping or remove possible confusion.

Using this newtype schema has allowed a few new instances to be added.  In
particular all the instances should have a [] or (Array Int) option for the
returned container.

-- 
Chris Kuklewicz



More information about the Libraries mailing list