[Haskell-cafe] Re: uu-parsinglib pKeyword

Stephen Tetley stephen.tetley at gmail.com
Wed Oct 28 13:49:47 EDT 2009


One of the parser combinator libraries for Clean had the (<:>)
combinator that captures the idiom (sorry!) in Doaitse's version.
Defined applicatively it would be:


(<:>) :: Applicative f => f a -> f [a] -> f [a]
(<:>) p1 p2 = (:) <$> p1 <*> p2

so pToken would be

pToken []       = pSucced []
pToken (x:xs) = pSym x <:> pToken xs

Admittedly this is not as succinct as

pToken = traverse pSym


... but I have used it from time to time.

Regards,

Stephen


2009/10/28 Ross Paterson <ross at soi.city.ac.uk>:
> On Wed, Oct 28, 2009 at 06:07:49PM +0100, S. Doaitse Swierstra wrote:
>> pToken []     = pSucceed []
>> pToken (x:xs) = (:) <$> pSym x <*> pToken xs
>>
>> pKeyword_Float = pToken "Float"
>
> pToken = traverse pSym
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list