4 -- |This is an auxiliary parser utilities. You usually don't have to
5 -- use this module directly.
6 module Network.HTTP.Lucu.Parser
11 import Control.Applicative
12 import Control.Applicative.Unicode
13 import Control.Monad.Unicode
14 import Data.Attoparsec
15 import Prelude.Unicode
17 -- |@'atMost' n v@ is like @'P.many' v@ but accumulates @v@ at most
19 atMost ∷ Alternative f ⇒ Int → f α → f [α]
22 atMost n v = ( (:) <$> v ⊛ atMost (n-1) v )
26 -- |@'finishOff' p@ is equivalent to @p '>>=' \a -> endOfInput '>>'
28 finishOff ∷ Parser α → Parser α
29 {-# INLINE finishOff #-}
30 finishOff = ((endOfInput *>) ∘ return =≪)