facebook / duckling

Language, engine, and tooling for expressing, testing, and evaluating composable language rules on input strings.
Other
4.05k stars 723 forks source link

Refactor unreadable use of sequence #606

Open chessai opened 3 years ago

chessai commented 3 years ago

Often in duckling we see

or . sequence $ [somePredicate, someOtherPredicate]

or

and . sequence $ [somePredicate, someOtherPredicate]

I would rather have functions

allOf, atLeastOneOf :: [a -> Bool] -> (a -> Bool)
allOf ps = and . sequence ps
atLeastOneOf ps = or . sequence ps

This is more readable IMO, and would be a trivial find+replace