Fail inside the context of a monad instead of erroring

This commit is contained in:
Joshua Clayton 2016-06-11 06:08:51 -04:00
parent 9c4f411168
commit f7421079f3

View File

@ -138,5 +138,5 @@ extractMatcher e p = either displayFailure (convertFoundObjectToMatcher p) e
convertFoundObjectToMatcher :: (Monad m, Alternative m) => m (Maybe a) -> (a -> b) -> m b
convertFoundObjectToMatcher p f = maybe empty (pure . f) =<< p
displayFailure :: T.Text -> a
displayFailure t = error $ "Parse error: '" ++ T.unpack t ++ "' is not a valid key in a singleOnly matcher"
displayFailure :: T.Text -> Y.Parser a
displayFailure t = fail $ "Parse error: '" ++ T.unpack t ++ "' is not a valid key in a singleOnly matcher"