[Haskell-cafe] uu-parsinglib pKeyword

Martijn van Steenbergen martijn at van.steenbergen.nl
Fri Oct 30 16:41:29 EDT 2009


Hi Ozgur,

Ozgur Akgun wrote:
> pKeyword_Int = ( \ _ _ _ -> "int" ) <$> pSym 'i' <*> pSym 'n' <*> pSym 't'
> pKeyword_Float = ( \ _ _ _ _ _ -> "float" ) <$> pSym 'f' <*> pSym 'l' 
> <*> pSym 'o' <*> pSym 'a' <*> pSym 't'
> 
> As you can see there is an obvious pattern if you try to capture a 
> "keyword". If there were a function called pKeyword taking a string as 
> an argument and producing the necessary parser, things would be easier.

I think pToken in Text.ParserCombinators.UU.Derived does what you want.

Groetjes,

Martijn.


More information about the Haskell-Cafe mailing list