Re: [Haskell-cafe] lost in generics
Hi Rustom, I tend to find that I use Uniplate for most stuff, and SYB for very complex stuff (SYB is quite a bit more complicated to do the simple things, but can do things out of reach for Uniplate). The example of manipulating AST's is very common, and using a generics library is a very good idea. One way to start would be to read the Uniplate manual: http://community.haskell.org/~ndm/darcs/uniplate/uniplate.htm - it even uses a simple expression type as the example. It has examples of all the functions, and also little exercises to try - even if you don't use Uniplate the exercises might give you practice figuring out what functions you're likely to end up using in your generics library. Thanks, Neil On Thu, Oct 20, 2011 at 6:12 PM, Rustom Mody rustompm...@gmail.com wrote: I need some help finding my way around the various generics libraries. My usage scenario is -- at least to start with -- the ASTs of programming languages. It appears to me that there are two generations of generics -- earlier there was generic haskell and strafunski Now there is uniplate and kure (and syb? -- not sure of its generation...) I get this impression because I saw a comment somewhat along these lines. And also the very first reference link on the strafunski webpage: http://www.haskell.org/haskellwiki/Applications_and_libraries/Generic_programming/Strafunski viz http://www.cs.vu.nl/Strafunski/ seems to be dead. So I am wondering whether strafunski is still under development or is it defunct? The following paras from http://www.cs.uu.nl/research/techreps/repo/CS-2008/2008-010.pdf The current status of generic programming in Haskell is comparable to the lazy Tower of Babel preceding the birth of Haskell in the eighties [Hudak et al., 2007]. We have many single-site languages or libraries, each individually lacking critical mass in terms of language/library-design effort, implementations, and users. Although generic programming has been used in several applications, it has few users for real-life projects. This is understandable. Developing a large application takes a couple of years, and choosing a particular approach to generic programming for such a project involves a risk. Few approaches that have been developed over the last decade are still supported, and there is a high risk that the chosen approach will not be supported anymore, or that it will change in a backwards-incompatible way in a couple of years time. sound omninous :-) In general my question is: What is alive/active and what is alive/active and what is -- um -- moved-on-from. And of course which are easier and which more difficult to dig into. Thanks Rusi ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] lost in generics
I need some help finding my way around the various generics libraries. My usage scenario is -- at least to start with -- the ASTs of programming languages. It appears to me that there are two generations of generics -- earlier there was generic haskell and strafunski Now there is uniplate and kure (and syb? -- not sure of its generation...) I get this impression because I saw a comment somewhat along these lines. And also the very first reference link on the strafunski webpage: http://www.haskell.org/haskellwiki/Applications_and_libraries/Generic_programming/Strafunski viz http://www.cs.vu.nl/Strafunski/ seems to be dead. So I am wondering whether strafunski is still under development or is it defunct? The following paras from http://www.cs.uu.nl/research/techreps/repo/CS-2008/2008-010.pdf The current status of generic programming in Haskell is comparable to the lazy Tower of Babel preceding the birth of Haskell in the eighties [Hudak et al., 2007]. We have many single-site languages or libraries, each individually lacking critical mass in terms of language/library-design effort, implementations, and users. Although generic programming has been used in several applications, it has few users for real-life projects. This is understandable. Developing a large application takes a couple of years, and choosing a particular approach to generic programming for such a project involves a risk. Few approaches that have been developed over the last decade are still supported, and there is a high risk that the chosen approach will not be supported anymore, or that it will change in a backwards-incompatible way in a couple of years time. sound omninous :-) In general my question is: What is alive/active and what is alive/active and what is -- um -- moved-on-from. And of course which are easier and which more difficult to dig into. Thanks Rusi ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] lost in generics
Hi Rusi, GHC has built-in support for two generic programming libraries. SYB [1] support has been there for a long time. The new generic mechanism [2], which allows you to define your own, (almost) derivable classes, only appeared in 7.2, but is planned to stay. What library you should use depends on what you want to do. There's a (slightly outdated) paper about that [3]. If you're looking into AST manipulations, SYB (or Uniplate [4]) might be the best pick. For most things I prefer the new generic mechanism, though. Cheers, Pedro [1] http://www.cs.uu.nl/wiki/GenericProgramming/SYB [2] http://www.haskell.org/ghc/docs/latest/html/users_guide/generic-programming.html [3] http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.140.3330 [4] http://community.haskell.org/~ndm/uniplate/ On Thu, Oct 20, 2011 at 18:12, Rustom Mody rustompm...@gmail.com wrote: I need some help finding my way around the various generics libraries. My usage scenario is -- at least to start with -- the ASTs of programming languages. It appears to me that there are two generations of generics -- earlier there was generic haskell and strafunski Now there is uniplate and kure (and syb? -- not sure of its generation...) I get this impression because I saw a comment somewhat along these lines. And also the very first reference link on the strafunski webpage: http://www.haskell.org/haskellwiki/Applications_and_libraries/Generic_programming/Strafunski viz http://www.cs.vu.nl/Strafunski/ seems to be dead. So I am wondering whether strafunski is still under development or is it defunct? The following paras from http://www.cs.uu.nl/research/techreps/repo/CS-2008/2008-010.pdf The current status of generic programming in Haskell is comparable to the lazy Tower of Babel preceding the birth of Haskell in the eighties [Hudak et al., 2007]. We have many single-site languages or libraries, each individually lacking critical mass in terms of language/library-design effort, implementations, and users. Although generic programming has been used in several applications, it has few users for real-life projects. This is understandable. Developing a large application takes a couple of years, and choosing a particular approach to generic programming for such a project involves a risk. Few approaches that have been developed over the last decade are still supported, and there is a high risk that the chosen approach will not be supported anymore, or that it will change in a backwards-incompatible way in a couple of years time. sound omninous :-) In general my question is: What is alive/active and what is alive/active and what is -- um -- moved-on-from. And of course which are easier and which more difficult to dig into. Thanks Rusi ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] lost in generics
On 20 October 2011 18:12, Rustom Mody rustompm...@gmail.com wrote: I need some help finding my way around the various generics libraries. My usage scenario is -- at least to start with -- the ASTs of programming languages. In general my question is: What is alive/active and what is alive/active and what is -- um -- moved-on-from. And of course which are easier and which more difficult to dig into. I'd group Strafunski, Uniplate and Kure together as they are all have extensive traversal control. Uniplate is a good choice as it is well documented and in active use. Kure is good if you know Strafunski, but might be a struggle to work with otherwise. Strafunski was pre-Hackage and used Drift for pre-processing so installing it nowadays would be a challenge. However, Strafunksi is well documented, especially the Design Patterns for Functional Strategic Programming[*] paper. Its worth reading this even if you don't use Strafunski. [*] http://arxiv.org/abs/cs/0204015 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] lost in generics
On 20 October 2011 19:12, Rustom Mody rustompm...@gmail.com wrote: And of course which are easier and which more difficult to dig into. If you're looking for an example for the new GHC generic mechanism: I recently added a generic default implementation to the ToJSON and FromJSON type classes of the aeson package (not in mainline yet): class ToJSON a where toJSON :: a - Value default toJSON :: (Generic a, GToJSON (Rep a)) = a - Value toJSON = gToJSON . from class FromJSON a where parseJSON :: Value - Parser a default parseJSON :: (Generic a, GFromJSON (Rep a)) = Value - Parser a parseJSON = fmap to . gParseJSON See: https://github.com/basvandijk/aeson/blob/newGenerics/Data/Aeson/Types/Internal.hs#L895 It wasn't that difficult to implement. However I did need to use some advanced type-level tricks to convert to and from records. Regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe