Building with ghc prints beautifully formatted error messages on powershell (as in other terminals):
PS > ghc .\src\XXX.hs -package ghc -package ghc-paths -package filepath
[1 of 1] Compiling XXX ( src\XXX.hs, src\XXX.o )
src\XXX.hs:340:9: error:
parse error on input `<-'
Perhaps this statement should be within a 'do' block?
|
340 | blah <- blah blah blah
| ^^
But when building through stack, something goes wrong:
PS > stack build
XXX-0.1.0.0: build (lib + exe)
Preprocessing library for XXX-0.1.0.0..
Building library for XXX-0.1.0.0..
[2 of 3] Compiling XXX ( src\XXX.hs, .stack-work\dist\5c8418a7\build\XXX.o )
←[;1msrc\XXX.hs:340:9: ←[;1m←[31merror:←[0m←[0m←[;1m←[0m←[0m←[;1m
parse error on input `<-'
Perhaps this statement should be within a 'do' block?←[0m←[0m
←[;1m←[34m |←[0m←[0m
←[;1m←[34m340 |←[0m←[0m blah ←[;1m←[31m<-←[0m←[0m blah blah blah
←[;1m←[34m |←[0m←[0m←[;1m←[31m ^^←[0m←[0m
←[0m←[0m←[0m
Is this a bug in stack, or is there a setting to fix it?
Thanks!
Introduction. GHCi is GHC's interactive environment, in which Haskell expressions can be interactively evaluated and programs can be interpreted.
You can find these sandboxed GHC installations in the ghc-* directories in the stack path --programs directory. If you would like Stack to use your system GHC installation, use the --system-ghc flag or run stack config set system-ghc --global true to make Stack check your PATH for a suitable GHC by default.
If you have installed the Haskell Platform, open a terminal and type ghci (the name of the executable of the GHC interpreter) at the command prompt. Alternatively, if you are on Windows, you may choose WinGHCi in the Start menu. And you are presented with a prompt. The Haskell system now attentively awaits your input.
stack ghci allows you to load components and files of your project into ghci . It uses the same TARGET syntax as stack build , and can also take options like --test , --bench , and --flag . Similarly to stack build , the default is to load up ghci with all libraries and executables in the project.
Turning off "use legacy console" in the cmd options does the trick!
Seems to be due to ansi color escape sequences - thanks @LotPings
Also: stack build --color never
gives monochrome but otherwise correctly formatted error messages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With