Reputation: 1829
Text.Regex.TDFA.Text
is the only one that provides instances for RegexLike Regex Text
using internal Text types.
Can instances of classes with Data.Text.Lazy
be derived from instances of Data.Text.Internal
? How can I improve this code?
import qualified Data.Text.Lazy as T
import Text.Regex.TDFA
import Text.Regex.Base.Context()
import Text.Regex.Base.RegexLike()
import Text.Regex.TDFA.Text
import Data.Function (on)
(<?>) :: T.Text -> T.Text -> Bool
(<?>) = on (=~) T.toStrict
Upvotes: 2
Views: 135
Reputation: 2909
I might be missing something, but it seems you have missed the module containing lazy Text
instances for the regex-tdfa classes . If that's what's happening, then you need only change
import Text.Regex.TDFA.Text
to
import Text.Regex.TDFA.Text.Lazy
Note that what is called Text
in the module Data.Text.Internal
is the same as what is called Text
in Data.Text
-- i.e., it's "strict" Text
. The lazy text type is defined in a different internal module (basically as a specialized list of strict texts.) So it's not as though these are two ways of viewing the same thing, if that's what you were thinking.
Upvotes: 4