mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-10-26 13:19:58 +03:00
Fail inside the context of a monad instead of erroring
This commit is contained in:
parent
9c4f411168
commit
f7421079f3
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user