12

I want to add ViewPatterns extensions to my build and currently I do it by adding the following lines to package.yaml

ghc-options:
- -Wall
- -XViewPatterns

I get a warning:

Warning: Instead of 'ghc-options: -XViewPatterns' use 'extensions:
ViewPatterns'

But, when I add an extensions field to package.yaml, I get the following:

WARNING: Ignoring unknown field "extensions" in package description

Also, I could not find any definition of extensions in the official stack documentation.

Asalle
  • 1,239
  • 19
  • 41

2 Answers2

23

Do not confuse stack with hpack.

package.yaml is actually read by hpack. But stack build command implicitly calls hpack to automatically convert into a cabal file, which may make you confused.

Anyway, to specify extensions in package.yaml, use default-extensions:

default-extensions: ViewPatterns
YAMAMOTO Yuji
  • 1,364
  • 9
  • 17
  • When I do this I get `Unrecognized field in ProjectAndConfigMonoid: default-extensions`, Is there something I need to include to make that field valid? – BWStearns Sep 22 '19 at 20:07
  • I can't diagnose by that error message. Can you post a question with the entire content of package.yaml? – YAMAMOTO Yuji Sep 24 '19 at 23:26
1

extensions: is currently unsupported by stack, see follow-ups in this github issue.

Asalle
  • 1,239
  • 19
  • 41