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 <[email protected]>: > 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 > [email protected] > http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
