tags:

views:

147

answers:

2

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?

+4  A: 

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.

Don Stewart
Why "Cross-Cutting" as a label for FFI and TH?
Jason Dusek
@Jason Dusek: Because they have a far-reaching impact on multiple aspects of the language, I imagine--either invoking arbitrary external code or making arbitrary changes to the code at compile time.
camccann
Oh, because they modify all aspects of the compiler and runtime: syntax, types, code generation and runtime support.
Don Stewart
+2  A: 

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.

Simon Marlow