don't create hints for errors without messages

This commit is contained in:
mrkkrp 2015-08-26 16:45:09 +06:00
parent 49e80775ef
commit 89f34688ab

View File

@ -163,8 +163,9 @@ newtype Hints = Hints [[String]] deriving Monoid
-- | Convert 'ParseError' record into 'Hints'. -- | Convert 'ParseError' record into 'Hints'.
toHints :: ParseError -> Hints toHints :: ParseError -> Hints
toHints err = Hints [messageString <$> msgs] toHints err = Hints hints
where msgs = filter ((== 1) . fromEnum) $ errorMessages err where hints = if null msgs then [] else [messageString <$> msgs]
msgs = filter ((== 1) . fromEnum) $ errorMessages err
-- | @withHints hs c@ makes “error” continuation @c@ use given hints @hs@. -- | @withHints hs c@ makes “error” continuation @c@ use given hints @hs@.