Salil
Salil

Reputation: 9722

How does Haskell scrap the boilerplate?

I am trying to wrap my head around this article:

http://www.haskell.org/haskellwiki/Scrap_your_boilerplate

Even though I know what fmap is and what a functor is (thanks to "Learn you a haskell for great good"), I am unable to understand this article. Can somebody explain to me in simple terms how Haskell scraps the boilerplate?

Upvotes: 9

Views: 1204

Answers (2)

Amber
Amber

Reputation: 526593

http://foswiki.cs.uu.nl/foswiki/GenericProgramming/SYB may be a better resource to read about SYB (a few of the links are broken because some things on haskell.org have changed urls, but the rest work).

To generally answer your question, here's a quote from the main page:

Datatype-generic programming

Datatype-generic programming consists of defining functions on the structure of datatypes, rather than on a datatype itself. In this way, one can define functions that work for many different datatypes.

In SYB, the structure of datatypes is not directly exposed to the programmer. Instead, generic combinators are used to define the generic functions. These combinators are implemented using fundamental functions from the Data and Typeable classes.

Upvotes: 4

sinelaw
sinelaw

Reputation: 16553

If you're new to haskell, you probably shouldn't worry at all about SYB. It's not something fundamental or even commonly used (I've never used it myself).

SYB is a library package for Haskell, not part of Haskell itself or even one of the base libraries. See here: http://www.cs.uu.nl/wiki/GenericProgramming/SYB

You may want to read through (the last paper in) http://research.microsoft.com/en-us/um/people/simonpj/papers/hmap/

Upvotes: 5

Related Questions