Haskell Ghc-mod Visual Studio Code For Mac?

Posted on  by 

Visual

  1. Visual Studio
  2. Visual Studio Code For Mac
  3. Haskell Ghc-mod Visual Studio Code For Mac Download

Extension for Visual Studio Code - An extension to use hlint in vscode.

Visual studio code for chromebook
Active2 years, 8 months ago

sorry for this really uninformed question but I'm trying out vs code right now and want to configure a task that's compiling the file I am working on. My folder structure and the configured task look like this:

The problem is, that this doesn't compile my app.hs source file but instead gives me the following ghc error: ghc: unrecognised flag: -o app app.hs. I have tested the command ghc -o app app.hs directly from the command prompt and it works just fine. So I think the error has something to do with the way vs code sends what I have written in tasks.json to the command prompt. I can't figure out what to do though. Does anybody have an idea?

Studio
Xam EseertsXam Eseerts

1 Answer

Thanks to @duplode and with a little playing around I now came up with the following task-setup (see picture below):

For answering my question only the first out of the three tasks I defined is of relevance. As you can see the trick was to change 'args: ['-o app app.hs']' to 'args: ['-o', 'app', 'app.hs']'. Please note however that -o app is not relevant and can be omitted in this case. The -o-flag is for renaming the ghc output files. If you omit this flag ghc will name all of the output files according to the input filename. So in my case the input file app.hs leads to the output files app.exe, app.o and app.hi. Only if you want to name your output files different from your input file does it make sense to use the -o-flag.

Visual Studio

As for the other two tasks I defined: If someone will ever read this and be interested in it, just comment or send me a message.

Xam EseertsXam Eseerts
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Not the answer you're looking for? Browse other questions tagged haskellvisual-studio-code or ask your own question.

I am happy to hear a news about Haskell support on Windows via Visual Studio Code and its extension called Haskelly. These days, my main operating system has been Windows 7 and 10. Linux is for running a web server, and Mac is for an old laptop. My students have extensively used Windows OS. For me to teach Haskell programming, I have no option but to find an appropriate IDE necessarily running on Windows. Sometime ago, I recommended Eclipse and Haskell plugin on it. Now I believe I will recommend Visual Studio Code and its extension called Haskelly for Haskell programming to my Windows-favored students.
[Haskelly]
  • https://marketplace.visualstudio.com/items?itemName=UCL.haskelly

  • Install Visual Studio Code
  • Run Visual Studio Code to activate the Haskelly extension
  • Download a stack installer and run it
  • Launch your CMD window or Windows PowerShell
  • Run 'stack install intero QuickCheck stack-run --install-ghc'
    • stack : the name of a command for Haskell tool stack
    • intero : a tool for auto-completion of names in Haskell programs
    • QuickCheck : a property-based testing tool
    • stack-run : an option to direct stack to compile the source codes and to run the default executable
    • --install-ghc : an option to install GHC (Glasgow Haskell compiler)
  • Rerun Visual Studio Code
  • Open a new file named Main.hs extension to write the following
    • module Main where
    • main = putStrLn 'Hello Haskell'
  • Run it!
Note. I guess you will meet some error messages: infero does not work. But VS code may work partially for Haskell programming, though type information is not properly displayed by infero when you hover a mouse cursor over some function.
In this error, you may try the following

Visual Studio Code For Mac

  • Run 'stack build intero', 'stack build QuickCheck', 'stack build stack-run' separately.
  • It may help you to build intero and QuickCheck at least.
  • But I failed to build stack-run with an error message like 'In the dependencies for unix-2.7.2.1: unbuildable must match <0, but the stack configuration has no specified version'
  • I do not know what solution is available for the problem.

Haskell Ghc-mod Visual Studio Code For Mac Download


Coments are closed