[Haskell-cafe] [Parsec] A combinator to match between M and N times?

Chris Kuklewicz haskell at list.mightyreason.com
Tue Aug 29 10:15:01 EDT 2006


I put the "try" in the wrong place.  Silly me

> -- This also works and uses <|> directly instead of via option
> countBetween' m n p | m<=n = do
>   xs <- count m p
>   let loop 0 acc = return (acc [])
>       loop i acc =
>         (do x <- try p
>             loop (pred i) (acc . (x:))) <|>
>         (return (acc []))
>   ys <- loop (n-m) id
>   return (xs++ys)




More information about the Haskell-Cafe mailing list