{-# LANGUAGE UnicodeSyntax #-} -- |This is an auxiliary parser utilities. You usually don't have to -- use this module directly. module Network.HTTP.Lucu.Parser ( atMost ) where import Control.Applicative import Control.Applicative.Unicode -- |@'atMost' n v@ is like @'P.many' v@ but accumulates @v@ at most -- @n@ times. atMost ∷ Alternative f ⇒ Int → f a → f [a] {-# INLINE atMost #-} atMost 0 _ = pure [] atMost n v = ( (:) <$> v ⊛ atMost (n-1) v ) <|> pure []