@@ -131,6 +131,7 @@ import Data.Attoparsec.Text.Internal (Parser, Result, parse, takeWhile1)
131131import Data.Bits (Bits, (.|.), shiftL)
132132import Data.Char (isAlpha, isDigit, isSpace, ord)
133133import Data.Int (Int8, Int16, Int32, Int64)
134+import Data.List (intercalate)
134135import Data.Text (Text)
135136import Data.Word (Word8, Word16, Word32, Word64, Word)
136137import qualified Data.Attoparsec.Internal as I
@@ -257,9 +258,10 @@ maybeResult _ = Nothing
257258-- | Convert a 'Result' value to an 'Either' value. A 'Partial' result
258259-- is treated as failure.
259260eitherResult :: Result r -> Either String r
260−eitherResult (T.Done _ r) = Right r
261−eitherResult (T.Fail _ _ msg) = Left msg
262−eitherResult _ = Left "Result: incomplete input"
261+eitherResult (T.Done _ r) = Right r
262+eitherResult (T.Fail _ [] msg) = Left msg
263+eitherResult (T.Fail _ ctxs msg) = Left (intercalate " > " ctxs ++ ": " ++ msg)
264+eitherResult _ = Left "Result: incomplete input"
263265
264266-- | A predicate that matches either a carriage return @\'\\r\'@ or
265267-- newline @\'\\n\'@ character.