haskell-hvr / regex-tdfa

Pure Haskell Tagged DFA Backend for "Text.Regex" (regex-base)
http://hackage.haskell.org/package/regex-tdfa
Other
36 stars 9 forks source link

What are all the supported return types for `=~`? #28

Open Martinsos opened 2 years ago

Martinsos commented 2 years ago

Hi, thanks for this great library!

You mention in docs https://hackage.haskell.org/package/regex-tdfa-1.3.1.1/docs/Text-Regex-TDFA.html common use cases, and there is 4 of them. I am wondering, is that all or are there other supported return types? If there are, how can we discover them?

What I am looking specifically is for a way to get all of the matches together with their match, before/afterMatch and submatches, but on the other hand I would also love to know in general what else is support in the return type.

Thanks!

andreasabel commented 2 years ago

Hi @Martinsos! The type of ~= is very polymorphic, see https://hackage.haskell.org/package/regex-tdfa-1.3.1.1/docs/Text-Regex-TDFA.html#v:-61--126- . So maybe you can get your use case by a suitable instantiation of the involved type classes RegexMaker and RegexContext.

I am just a formal maintainer, I have not tried to use this package in earnest. If you want to discuss a specific implementation problem, stackoverflow or the haskell-cafe mailing list might be suitable venues.

If you have a useful addition to the documentation, consider a submitting a PR.

Martinsos commented 2 years ago

Thanks @andreasabel ! I have to admit reading the definition of =~ got me a bit confused, and while I don't want to waste any more of your time, I was hoping you could just point me a bit in the direction that might help me understand it better: I see the RegexContext Regex source1 target constraint -> so this is dictating what target can be. However, looking at list of instances below, I see only a couple of possible value for target: String, ByteString, Text and Seq Char. On the other hand, I know that I can specity output to be more complex stuff like (String, String, String, [String]) and similar. So obviously I am looking at it the wrong way somehow -> how should I look at it to be able to figure out which types are supported for target?

Thanks!

andreasabel commented 2 years ago

(While I cannot contribute anything now, I leave this issue open so passers-by can get involved.)