Gabriel Gonzalez recently wrote an article entitled Advice for Haskell beginners and I was mildly surprised to see that out of four tips, one was:

Avoid typeclass abuse

On second thought, though, this is important advice. In retrospect, my inclination to use typeclasses in inappropriate ways was a big problem in my earlier Haskell days. I made this mistake a lot:

I thought Java interfaces mapped to Haskell typeclasses.

But really, more often they map to Haskell records .

Julie Moronuki and I have written fairly extensively about the extent to which interfaces and typeclasses can be compared. (Summary of our conclusion: they share a related conceptual purpose but are not directly analogous.) Here I want to share a quick example of how they do map to records, by translating a Java example into Haskell.