Difference between revisions of "Use of language extensions"

From HaskellWiki
Jump to navigation Jump to search
(title of initial mail)
m
Line 25: Line 25:
 
* Initiating mail on Haskell Cafe: [http://www.haskell.org/pipermail/haskell-cafe/2005-May/010085.html When to use fancy types]
 
* Initiating mail on Haskell Cafe: [http://www.haskell.org/pipermail/haskell-cafe/2005-May/010085.html When to use fancy types]
 
* GHC ticket on [http://hackage.haskell.org/trac/ghc/ticket/3085 warn about language extensions that are not used]
 
* GHC ticket on [http://hackage.haskell.org/trac/ghc/ticket/3085 warn about language extensions that are not used]
* Haskell Cafe on [http://www.haskell.org/pipermail/haskell-cafe/2009-April/059206.htmlList and description of language extensions]
+
* Haskell Cafe on [http://www.haskell.org/pipermail/haskell-cafe/2009-April/059206.html List and description of language extensions]
   
 
[[Category:Style]]
 
[[Category:Style]]

Revision as of 09:22, 19 May 2009

Haskell compilers are full of experimental features. However, when it comes to designing libraries one should carefully think about which extensions to use and which not. Every required language extension and every imported library which on its own depends on such an extension, causes some of the following problems:

  • It limits the range of Haskell compilers you can use.
  • According to the availability of compilers on different platforms, it will also limit the range of machines it can be run on.
  • It complicates the installation, if a user has to install a particular compiler to use your library.
  • Many extensions are complicated enough to produce even more incomprehensible error messages, than errorneous Haskell 98 programs.
  • Even with the same compiler, in a year or two your code might need fixing if the extension or implementation is sufficiently experimental (for example, the rules for what type-signatures GADTs require, has changed from GHC 6.4 to 6.6 to 6.8 to 6.10). People who depend on your library may be impatient to upgrade to the newest version of GHC.

We suggest the following hierarchy of complexity with respect to types:

  • Simple algebraic types
  • H98 type classes
  • Fancier instance heads (but still single-parameter, non-overlapping)
  • Existential and local universal quantification
  • GADTs (I'm still uncertain about this judgement, but they seem to be less troublesome than...)
  • Multiparameter type classes with functional dependencies
  • Multiparameter type classes including undecidable instances, overlapping instances

We recommend to explicitly switch on language extensions that are needed using the LANGUAGE pragma instead of switching them on all at once using the -fglasgow-exts compiler flag.

See also