Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Categorizing GHC extensions

I was wondering if GHC's extensions can be divided into basically two different categories

  • those that provide "syntactic suggar" or convenience
  • and those that introduce something new, a new paradigm for instance.

Now provided one could divide the existing extensions into the above categories which extension would fit into which category?

like image 505
Guenni Avatar asked Jun 23 '10 18:06

Guenni


2 Answers

I think a more appropriate categorization would be to divide it up by the compiler pipeline:

Syntactic extensions

  • -XMagicHash
  • -XUnicodeSyntax
  • -XNewQualifiedOperators
  • -XViewPatterns
  • -XNPlusKPatterns
  • -XDoRec
  • -XTransformListComp
  • -XNoImplicitPrelude
  • -XPostfixOperators
  • -XTupleSections
  • -XDisambiguateRecordFields
  • -XNamedFieldPuns
  • -XRecordWildCards
  • -XPackageImports
  • -XExplicitForAll
  • -XKindSignatures
  • ...

Type System Extensions

  • -XUnboxedTuples
  • -XLiberalTypeSynonyms
  • -XGADTs
  • -XMultiParamTypeClasses
  • -XFlexibleContexts
  • -XConstrainedClassMethods
  • -XOverlappingInstances and -XIncoherentInstances
  • -XTypeFamilies
  • -XImplicitParams

Cross-cutting extensions

  • -XTemplateHaskell
  • -XForeignFunctionInterface

Optimizatsions

  • -fenable-rewrite-rules
  • -fspec-constr
  • -O2

Code Generation Extensions

  • -fllvm
  • -fasm
  • -fvia-C

Runtime Extensions

  • -threaded

What do you think? Not every flag is either (a) definable in terms of existing constructions, or (b) a new part of the compiler. It's more subtle.

There are many other extensions too, see if you can classify them in this form.

like image 87
Don Stewart Avatar answered Oct 08 '22 18:10

Don Stewart


The flags are already categorized in the flag reference in the GHC's users guide, and the language extensions are broken down into various categories in the section on language features.

like image 31
Simon Marlow Avatar answered Oct 08 '22 19:10

Simon Marlow