I am trying to compile a regexp and get an error message that can be presented to the user. I tried this with Text.Regex.TDFA and Text.Regex.Posix and it seems to behave the same:
Prelude Text.Regex.TDFA Data.Maybe Data.Either.Utils> fromLeft $ (makeRegexM ".[" :: Either String Regex)
"*** Exception: parseRegex for Text.Regex.TDFA.String failed:".[" (line 1, column 3):
unexpected end of input
expecting "^", "]", "-" or Failed to parse bracketed string
Prelude Text.Regex.TDFA Data.Maybe Data.Either.Utils> isJust $ (makeRegexM ".[" :: Maybe Regex)
False
Prelude Text.Regex.TDFA Data.Maybe Data.Either.Utils> isJust $ (makeRegexM "." :: Maybe Regex)
True
The Maybe monad seems to work; the Either does not. However the documentation says, it should use 'fail' - which, as far as I know, is defined in Either monad. Am I doing something wrong?