[clean-list] Parsing: to drill or not to drill, that is the question

zuurb078 at planet.nl zuurb078 at planet.nl
Mon Sep 1 09:14:53 MEST 2008


I just wrote constantWind to be working on a list of Char. Only after that I found out I wanted to combine it with parsers working on a list of [Char]. It shows that you can reuse the constantWind parser without having to re-engineer it to work on a list of [Char]. you could have done the latter also.
Erik Zuurbier

________________________________

Van: clean-list-bounces at science.ru.nl namens metaperl
Verzonden: do 28-8-2008 16:30
Aan: clean-list at science.ru.nl
Onderwerp: [clean-list] Parsing: to drill or not to drill, that is the question




surfaceWind is a parser engineered to operate on [Char]

however constantWind is a parser engineered to operate on Char... but it
then gets applied via drill to create a parser which operates on [Char]

Why would one be indirect and create a parser to operate on Char and then
apply 'drill' to get what you intended to use:

surfaceWind :: Parser [Char] SurfaceWind t
surfaceWind = "Surface Wind" :> p
where   p       = (word constantWind) <&> \surfaceWind -> <!?> (word
directionVariation)
                                                        (\dir2->{surfaceWind & direction=dir2}) // if found
                                                        surfaceWind                                     // if nothing found

constantWind :: Parser Char SurfaceWind a
constantWind =  direction       <&> \dir         ->
                                speed           <&> \(u,spd) ->
                                gust u          <@  \g           -> {direction=dir,speed=spd,gust=g}

--
View this message in context: http://www.nabble.com/Parsing%3A-to-drill-or-not-to-drill%2C--that-is-the-question-tp19201847p19201847.html
Sent from the Clean mailing list archive at Nabble.com.

_______________________________________________
clean-list mailing list
clean-list at science.ru.nl
http://mailman.science.ru.nl/mailman/listinfo/clean-list


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.science.ru.nl/pipermail/clean-list/attachments/20080901/030f0682/attachment.html


More information about the clean-list mailing list