[Haskell-cafe] Language.Haskell.Parser question
vasyl.pasternak at gmail.com
Thu Mar 26 18:38:40 EDT 2009
Wow, uniplate is the library from my dreams :)
I knew there should be easy, elegant and simple solution (I hate brute
force, that's why I start using Haskell).
2009/3/26 Neil Mitchell <ndmitchell at gmail.com>:
>> f1 = foo 5
>> f2 = foo 8
>> f3 = foo 9
>> I want to extract a list [5, 8, 9] (suppouse function takes only one argument)
> Firstly, use haskell-src-exts and Language.Haskell.Exts - its a much
> better library, deals with many extensions, and gives you everything
> Language.Haskell did.
>> parser works pretty good,
>> but its output data type is terrible. As I understand, I need to
>> extract all objects that looks like
>> HsApp (HsVar (UnQual (HsIdent "foo"))) ....
> It's trivial, if you use a generics solution, say Uniplate:
> [x | App foo x <- universeBi src, prettyPrint foo == "foo" ]
> I often use prettyPrint to follow down Ident/Qual/UnQual paths without
> having to know as much of the data type. Using universeBi makes it
> easy to find everything that occurs everywhere.
> If you attempt this without using a generics library, I'd say you are
> destined to fail.
More information about the Haskell-Cafe