From b19dae4315482eafb1ed300c9725cfe3b7dd3704 Mon Sep 17 00:00:00 2001 From: mrkkrp Date: Fri, 31 Jul 2015 01:43:25 +0600 Subject: [PATCH] improve efficiency of applicative interface --- Text/MegaParsec/Prim.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Text/MegaParsec/Prim.hs b/Text/MegaParsec/Prim.hs index 694defb..4ee0804 100644 --- a/Text/MegaParsec/Prim.hs +++ b/Text/MegaParsec/Prim.hs @@ -172,8 +172,10 @@ parsecMap f p = ParsecT $ \s cok cerr eok eerr -> unParser p s (cok . f) cerr (eok . f) eerr instance A.Applicative (ParsecT s u m) where - pure = return - (<*>) = ap -- TODO: Can this be optimized? + pure = return + (<*>) = ap -- TODO: Can this be optimized? + (*>) = (>>) + p1 <* p2 = do { x1 <- p1 ; void p2 ; return x1 } instance A.Alternative (ParsecT s u m) where empty = mzero