regex-* packages (was Re: base libraries)
Ross Paterson
ross at soi.city.ac.uk
Fri Nov 24 09:41:33 EST 2006
On Thu, Nov 23, 2006 at 10:20:51AM +0000, Chris Kuklewicz wrote:
> Some of the other regex-* libraries are interfaces to c-library backends
> (pcre and tre) and it is not GHC's place to come with copies of those
> libraries. But GHC used regex internally, so it must come with at
> least a single backend.
A problem with these packages is that they're a good deal less portable
than the Text.Regex they replaced. They use multi-parameter type classes,
but they also rely on late overlapping resolution, which is a GHC-only
feature. That is, instances overlap, but they're only used outside of
the overlap, e.g.:
instance (RegexLike a b) => RegexContext a b (Array Int b)
instance (RegexLike a b) => RegexContext a b MatchArray
type MatchArray = Array Int (MatchOffset, MatchLength)
type MatchOffset = Int
type MatchLength = Int
These overlap at RegexContext a (Int,Int) (Array Int (Int,Int)), but
as long as you don't use that instance GHC doesn't complain. (And you
won't, because there's no instance RegexLike a (Int,Int), but overlaps
are decided by comparing instance heads only.) Similarly
instance (RegexLike a b) => RegexContext a b [Array Int b]
instance (RegexLike a b) => RegexContext a b [MatchArray]
and also
instance (RegexLike a b) => RegexContext a b [b]
instance (RegexLike a b) => RegexContext a b [MatchArray]
instance (RegexLike a b) => RegexContext a b [(MatchOffset,MatchLength)]
Can anything be done about that?
More information about the Libraries
mailing list