Difference between revisions of "Slim instance declaration"

From HaskellWiki
Jump to navigation Jump to search
(taken from a post to libraries mailing list)
 
(reference to Haskell-Cafe moved to "See also")
 
Line 1: Line 1:
This is an excerpt from "Disclipline for re-use: Slim instances"
 
http://www.haskell.org/pipermail/libraries/2006-September/005791.html
 
 
 
== All instance declarations should be slim. ==
 
== All instance declarations should be slim. ==
   
Line 14: Line 11:
 
and less re-invention of mostly trivial wheels.
 
and less re-invention of mostly trivial wheels.
   
  +
  +
== See also ==
  +
 
* Haskell-Cafe: [http://www.haskell.org/pipermail/libraries/2006-September/005791.html Disclipline for re-use: Slim instances]
   
 
[[Category:Style]]
 
[[Category:Style]]

Latest revision as of 06:09, 5 September 2007

All instance declarations should be slim.

This means

  • Instance declarations (and default definitions) should never contain non-trivial function definitions.
  • Instance declarations (and default definitions) should only provide "plumbing" to make existing functions accessible via the type class resolution mechanism.
  • The "plumbed" functions should always be exported (since instances are always exported).

Since the naming will not always be straight-forward, the last point is particularly important and would enable more re-use and less re-invention of mostly trivial wheels.


See also