P. 1
Fun and generic things to do with EMGM - London HUG - 9 July 2009

Fun and generic things to do with EMGM - London HUG - 9 July 2009

4.0

|Views: 134|Likes:
Published by Sean Leather
Generic programming has become a popular technique for reducing code and simplifying programs. There are many libraries for Haskell programmers that offer different approaches to generic programming. This talk introduces one such library, Extensible and Modular Generics for the Masses (EMGM), that was uploaded to Hackage for the first time in September 2008. EMGM uses type classes to provide a sum-of-products representation of datatypes. Not quite as well-known as its cousin, Scrap Your Boilerplate, EMGM also provides a wealth of generic functions. Additionally, EMGM allows programmers to easily write their own generic functions and specialize any function for arbitrary datatypes. In this talk, we look at the building blocks of EMGM, at various generic functions provided by the library, how do define one’s own generic function, and at some potential uses.

Sean Leather is a PhD student at Utrecht University in the Netherlands. His research focuses on exploring libraries for generic programming in Haskell.
Generic programming has become a popular technique for reducing code and simplifying programs. There are many libraries for Haskell programmers that offer different approaches to generic programming. This talk introduces one such library, Extensible and Modular Generics for the Masses (EMGM), that was uploaded to Hackage for the first time in September 2008. EMGM uses type classes to provide a sum-of-products representation of datatypes. Not quite as well-known as its cousin, Scrap Your Boilerplate, EMGM also provides a wealth of generic functions. Additionally, EMGM allows programmers to easily write their own generic functions and specialize any function for arbitrary datatypes. In this talk, we look at the building blocks of EMGM, at various generic functions provided by the library, how do define one’s own generic function, and at some potential uses.

Sean Leather is a PhD student at Utrecht University in the Netherlands. His research focuses on exploring libraries for generic programming in Haskell.

More info:

Published by: Sean Leather on Jul 10, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF or read online from Scribd
See more
See less

02/04/2013

pdf

Fortunately, we don’t have to write all of the previous
boilerplate. We can generate it using the Template Haskell
functions included in the emgm package.

$ (derive ’’ Tree)

This creates the EP, the ConDescr and TypeDescr, and all class
instances needed.

It is a good idea to understand what code is being derived. Use
the following pragma or command-line option in GHC to see
the code generated at compile time:

{-# OPTIONS -ddump-splices #-}

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->