You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Goal: fail to an error based on checking a parsed value using a predicate.
Something like:
// (a -> Bool) -> Parser e s (m t) a -> e -> Parser e s (m t) a
function checkError(predicate, parser, errorValue) {
checkFunction('checkError', predicate);
checkParser('checkError', parser);
return bind(parser, (value) => predicate(value) ? pure(value) : error(errorValue));
// or:
return bind(parser, (value) => (predicate(value) ? pure : error)(value));
}
Needs corner cases to be hammered out and a better name, of course.
Cases:
parser fails -> fail
parser errors -> error
parser succeeds
predicate passes -> success
predicate fails -> error
Another implementation possibility, which doesn't work because it doesn't pass the test case for "parser fails -> fail":
// (a -> Bool) -> Parser e s (m t) a -> e -> Parser e s (m t) a
function checkError(predicate, parser, e) {
return alt([check(predicate, parser), error(e)]);
}
The text was updated successfully, but these errors were encountered:
Goal: fail to an error based on checking a parsed value using a predicate.
Something like:
Needs corner cases to be hammered out and a better name, of course.
Cases:
parser
fails -> failparser
errors -> errorparser
succeedspredicate
passes -> successpredicate
fails -> errorAnother implementation possibility, which doesn't work because it doesn't pass the test case for "
parser
fails -> fail":The text was updated successfully, but these errors were encountered: