haskell - Avoiding boilerplate when dealing with many unrelated types -


I am writing code which is related to values, where many types of types are defined that the structure of the Haskell module To mirror:

  data module l = ... data decl l = ... data exp = t ... ... etc  

I like to be able to write the tasks that these data structures run and make different changes on them. Because there is no normal data type, I can not write a task that does everything.

So far, I have typed a tree that wraps each of these types of my conversion function tree L -> Tree l :

  Data Tree L = Module T (Module L). DCLT (DCLL) | EXPT (XPL) - Copy & amp; Paste  

Although I'm now writing a lot of code which takes a module , it wraps it to moduleT , one Function calls, then reopens the result back to the module . I have:

  class annotated tree ast where tree :: Este L -> gt; Tree L Untry :: Tree L - & gt; Just L Image AnnotatedTree module where tree = module unit (module T x) = X unity _ = error "expected module" - etc. Advertise: << / code> 

Two questions:

  1. Given that I can not change the types of languages. Examples. Exposed Syntax, am I going to go wrong about this?
  2. If not, can I cut it on any boilerplate anyway?

All those types seem to be typing and examples of data. You can define your type of tree type to be an example of typing and data, and then easily use one of the generic libraries (SYB, uniplate, ...) available to cross the tree. Please.

My personal favorite is analog, for example, it would be easy to gather all the Garded Alt from the pad:

  Import data. Uniplate.PlateData ... allGuardedAlts :: tree l - & gt; [L] allGuardedAlts T = [L | Protected Alt L_ _ and Lieutenant - Universe Tt]  

You can put a look at your package, where I did the same.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -