38

I wanted to use {-# LANGUAGE OverloadedStrings #-} but I forgot how it's called. This kind of thing isn't hoogle-able, and also it takes some time finding using google*.

Is there somewhere a list of GHC extensions named as they are in the LANGUAGE pragma?

* My googling search journey:

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
yairchu
  • 23,680
  • 7
  • 69
  • 109

7 Answers7

29

ghci's tab-completion knows. Type :set -X at a ghci prompt, then hit Tab, and you'll get a full list. Or :set -XFoo then Tab will get you a list of all extensions beginning with Foo.

Ganesh Sittampalam
  • 28,821
  • 4
  • 79
  • 98
25

The "Language options" section of the flag reference page has a list that's much more easily browseable than the language features page.

Once you're there a Ctrl-F search for "overloaded" takes you right to what you want.

Travis Brown
  • 138,631
  • 12
  • 375
  • 680
  • 5
    Yep, and the ghc man page is also good. Always makes me feel sorry for people on manless platforms. – Thomas M. DuBuisson Jun 08 '10 at 15:47
  • The most recent docs for language extensions is https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/exts.html, and the most recent GHC flags docs is https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/flags.html – zbw Feb 14 '21 at 07:37
22
$ ghc --supported-languages

(from GHC docs)

yairchu
  • 23,680
  • 7
  • 69
  • 109
3

ghc-mod for Emacs found here: http://hackage.haskell.org/package/ghc-mod, includes completion for language extensions. If you are an Emacs user, I suggest you to try it.

amindfv
  • 8,438
  • 5
  • 36
  • 58
Tener
  • 5,280
  • 4
  • 25
  • 44
  • Also with Spacemacs `SPC I s` starts ya-snippet with helm which is very handy to insert language extension. – mb14 Aug 27 '18 at 20:12
3

When using Leksah IDE, selecting Package menu, then Edit Package menu item, then Extension tab also gives you a checkable list.

DonnyD
  • 211
  • 2
  • 10
2

My dumb hacky way of doing such things:

$ man ghc | grep String
       -XExtendedDefaultRules   -XNoExtendedDefaultRules   -XOverloadedStrings
       -XNoOverloadedStrings  -XGADTs -XNoGADTs   -XGADTSyntax  -XNoGADTSyntax
Dan Burton
  • 53,238
  • 27
  • 117
  • 198
1

The Cabal package provides a Language.Haskell.Extension module which exports a KnownExtension type whose each constructor is an extension.

The documentation of each constructor briefly describes the extension and provides a link to the GHC user guide.

Damien Flament
  • 1,465
  • 15
  • 27