How do I enable language extensions from within GHCi?
Asked Answered
F

1

132

I'm trying to enable XRankNTypes in GHCi. How do I do this?

Firecracker answered 25/9, 2012 at 14:15 Comment(0)
P
190

:set -XRankNTypes. The -X part is a compiler switch, by the way, extension is called just RankNTypes.

Piffle answered 25/9, 2012 at 14:17 Comment(7)
Note that after typing :set -X in GHCi you'll actually get tab completion for available extensions, which is handy when you can't remember where they decided to use abbreviations ("MultiParam") or acronyms ("GADT") rather than spelling things out in full ("MonomorphismRestriction")...Lou
And if you, a beginning Haskell programmer, don't also get such tab completion in your editor of choice then fix up you programming environment!Prouty
@ThomasM.DuBuisson -- are you referring to autocompletion within one's text editor? If so, do you know if this is possible with vim?Herrod
@Herrod I use neocomplcache, neco-ghc, ghcmod-vim, and vim2hs for my vim+Haskell needs. When I type something like run, I get a list of possible completions popping up (in a particular project that imports cereal) such as run{Get,Put}{,Lazy}, runPutM, etc.Prouty
@ThomasM.DuBuisson Thank you. I just tried all of those out now, on Windows. It seems neco-ghc fails completely for me, making my environment nigh unusable. vim2hs doesn't work very well either, and while I'm certain this can all be fixed, it'll probably take too much time and hassle to be worth it.Herrod
@identity: neco-ghc and ghcmod-vim work fine for me on Windows. Did you install ghcmod?Piffle
There is actually an opportunity for improving error messages here. Instead of e.g. ` Illegal tuple section: use TupleSections` a better message would be ` Illegal tuple section: use :set -XTupleSections to enable the TupleSections language extension'.Publish

© 2022 - 2024 — McMap. All rights reserved.