Visual Studio Code Haskell



  1. Visual Studio Code Haskell Key
  2. Visual Studio Code Download

Run code snippet or code file for multiple languages: C, C++, Java, JavaScript, PHP, Python, Perl, Perl 6, Ruby, Go, Lua, Groovy, PowerShell, BAT/CMD, BASH/SH, F# Script, F# (.NET Core), C# Script, C# (.NET Core), VBScript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, OCaml Script, R, AppleScript, Elixir, Visual Basic .NET, Clojure, Haxe, Objective-C, Rust, Racket, Scheme, AutoHotkey, AutoIt, Kotlin, Dart, Free Pascal, Haskell, Nim, D, Lisp, Kit, V, SCSS, Sass, CUDA, Less, Fortran, and custom command

Azure Tools for Visual Studio Code - This extension for Visual Studio Code gives Azure developers some convenient commands for creating or accessing resources directly in the editor. Mark down preview - Markdown Preview Enhanced is an extension that provides you with many useful functionalities such as automatic scroll sync, math typesetting. MacOS: Press Cmd+P in your Visual Studio Code, type in ext install Tabnine.tabnine-vscode and press Enter. Windows: Press Ctrl+P in your Visual Studio Code, type in ext install Tabnine.tabnine-vscode and press Enter. Click the Reload button in the extensions tab. The default behavior of Tabnine is using the Enter key to accept completions. MacOS: Press Cmd+P in your Visual Studio Code, type in ext install Tabnine.tabnine-vscode and press Enter. Windows: Press Ctrl+P in your Visual Studio Code, type in ext install Tabnine.tabnine-vscode and press Enter. Click the Reload button in the extensions tab. The default behavior of Tabnine is using the Enter key to accept completions. VS Code is a general code/scripting IDE built to be lightweight and for people familiar with their language of choice, not directly comparable to Visual Studio in power or scope. VS Code is a general code/scripting IDE built to be lightweight and for people familiar with their language of choice, not directly comparable to Visual Studio in power or scope.

Sponsors

Increase your coding productivity with Tabnine’s AI code completions! Tabnine is a free powerful Artificial Intelligence assistant designed to help you code faster, reduce mistakes, and discover best coding practices - without ever leaving the comfort of VS Code.

Tabnine is trusted by more than a million developers worldwide. Get it now.

Eliminate context switching and costly distractions. Create and merge PRs and perform code reviews from inside your IDE while using jump-to-definition, your keybindings, and other IDE favorites. Learn more.

Book for VS Code

《Visual Studio Code 权威指南》:带你深入浅出 VS Code!

WeChat Official Account

VS Code 的热门文章、使用技巧、插件推荐、插件开发攻略等,请关注“玩转VS Code”公众号!

Donation

If you like this extension, you could become a backer or sponsor via Patreon, donate via PayPal, or scan below QR code to donate via Alipay. Any amount is welcome. It will encourage me to make this extension better and better!

Features

  • Run code file of current active Text Editor
  • Run code file through context menu of file explorer
  • Run selected code snippet in Text Editor
  • Run code per Shebang
  • Run code per filename glob
  • Run custom command
  • Stop code running
  • View output in Output Window
  • Set default language to run
  • Select language to run
  • Support REPL by running code in Integrated Terminal

Usages

  • To run code:
    • use shortcut Ctrl+Alt+N
    • or press F1 and then select/type Run Code,
    • or right click the Text Editor and then click Run Code in editor context menu
    • or click Run Code button in editor title menu
    • or click Run Code button in context menu of file explorer
  • To stop the running code:
    • use shortcut Ctrl+Alt+M
    • or press F1 and then select/type Stop Code Run
    • or right click the Output Channel and then click Stop Code Run in context menu
  • To select language to run, use shortcut Ctrl+Alt+J, or press F1 and then select/type Run By Language, then type or select the language to run: e.g php, javascript, bat, shellscript...
  • To run custom command, then use shortcut Ctrl+Alt+K, or press F1 and then select/type Run Custom Command

Configuration

Make sure the executor PATH of each language is set in the environment variable.You could also add entry into code-runner.executorMap to set the executor PATH.e.g. To set the executor PATH for ruby, php and html:

Supported customized parameters

  • $workspaceRoot: The path of the folder opened in VS Code
  • $dir: The directory of the code file being run
  • $dirWithoutTrailingSlash: The directory of the code file being run without a trailing slash
  • $fullFileName: The full name of the code file being run
  • $fileName: The base name of the code file being run, that is the file without the directory
  • $fileNameWithoutExt: The base name of the code file being run without its extension
  • $driveLetter: The drive letter of the code file being run (Windows only)
  • $pythonPath: The path of Python interpreter (set by Python: Select Interpreter command)

Please take care of the back slash and the space in file path of the executor

  • Back slash: please use
  • If there ares spaces in file path, please use ' to surround your file path

You could set the executor per filename glob:

Besides, you could set the default language to run:

For the default language: It should be set with language id defined in VS Code. The languages you could set are java, c, cpp, javascript, php, python, perl, ruby, go, lua, groovy, powershell, bat, shellscript, fsharp, csharp, vbscript, typescript, coffeescript, swift, r, clojure, haxe, objective-c, rust, racket, ahk, autoit, kotlin, dart, pascal, haskell, nim, d, lisp

Also, you could set the executor per file extension:

To set the custom command to run:

To set the the working directory:

To set whether to clear previous output before each run (default is false):

To set whether to save all files before running (default is false):

To set whether to save the current file before running (default is false):

To set whether to show extra execution message like [Running] ... and [Done] ... (default is true):

[REPL support] To set whether to run code in Integrated Terminal (only support to run whole file in Integrated Terminal, neither untitled file nor code snippet) (default is false):

Visual Studio Code Haskell

To set whether to preserve focus on code editor after code run is triggered (default is true, the code editor will keep focus; when it is false, Terminal or Output Channel will take focus):

code-runner.ignoreSelection: Whether to ignore selection to always run entire file. (Default is false)

code-runner.showRunIconInEditorTitleMenu: Whether to show 'Run Code' icon in editor title menu. (Default is true)

code-runner.showRunCommandInEditorContextMenu: Whether to show 'Run Code' command in editor context menu. (Default is true)

code-runner.showRunCommandInExplorerContextMenu: Whether to show 'Run Code' command in explorer context menu. (Default is true)

code-runner.terminalRoot: For Windows system, replaces the Windows style drive letter in the command with a Unix style root when using a custom shell as the terminal, like Bash or Cgywin. Example: Setting this to /mnt/ will replace C:path with /mnt/c/path (Default is ')

code-runner.temporaryFileName: Temporary file name used in running selected code snippet. When it is set as empty, the file name will be random. (Default is 'tempCodeRunnerFile')

code-runner.respectShebang: Whether to respect Shebang to run code. (Default is true)

About CWD Setting (current working directory)

  1. By default, use the code-runner.cwd setting
  2. If code-runner.cwd is not set and code-runner.fileDirectoryAsCwd is true, use the directory of the file to be executed
  3. If code-runner.cwd is not set and code-runner.fileDirectoryAsCwd is false, use the path of root folder that is open in VS Code
  4. If no folder is open, use the os temp folder

Note

  • For Objective-C, it is only supported on macOS
  • To run C# script, you need to install scriptcs
  • To run TypeScript, you need to install ts-node
  • To run Clojure, you need to install Leiningen and lein-exec
Visual

Telemetry data

By default, telemetry data collection is turned on to understand user behavior to improve this extension. To disable it, update the settings.json as below:

Visual Studio Code Haskell Key

Change Log

See Change Log here

Issues

Submit the issues if you find any bug or have any suggestion.

Contribution

Fork the repo and submit pull requests.

In this post we will walk you through a basic Haskell setup utilizing Visual Studio Code (Code Editor / IDE). We will need to install Visual Studio Code, GHC (the Glasgow Haskell Compiler), Stack(Haskell build tool), Cabal (Haskell package manager / build tool), Haskero (Visual Studio plugin that enables Haskell support), and Intero (powers the IDE like features in Haskero).

Install Visual Studio Code

Let’s start off by installing Visual Studio Code. Head to https://code.visualstudio.com/ and download the correct version for your operating system and install it.

Install Haskell Platform

Next let’s go ahead and go to https://www.haskell.org/platform/ and download the latest version of the Haskell Platform for your operating system and install it (in some cases you can simply install it with your OS’s package manager). The Haskell Platform includes GHC, Cabal, and Stack (all of which we need).

Load up a terminal window (or command-prompt in windows) and try the following commands (to output the version of each) to make sure they all installed successfully.

Test for GHC’s version: ghc --version

Test for Cabal’s version: cabal --version

Test for Stack’s version: stack --version

If any of them did not install (ie. the command is unrecognized) then you’ll need to go to their respective page (GHC, Cabal, Stack) and follow the instructions.

Install Haskero in Visual Studio Code

Load up Visual Studio Code. Click on the Extensions Icon of the far left (it looks like a square and is at the bottom of the icons list). Search for the Haskero extension. Install Haskero by clicking on the install button. Exit out of Visual Studio Code after installing Haskero.

Creating your first Haskell Project using Stack

Open up a terminal window and navigate to the directory you wish to create your haskell project in. Type the following command:

This creates a stack project named MyFirstHaskellProject using the new-template template. This creates a directory named MyFirstHaskellProject in the working directory which contains the project. MyFirstHaskellProject can be changed to whatever name desired. Different templates can be used other then the new-template template when started a new project. The templates available can be listed out by typing stack templates in the terminal.

Adding Intero to your Project

NOTE: you may need to upgrade your stack version & try again if the following steps fail.

Now that we’ve made a project go ahead and change directories to the MyFirstHaskellProject directory created by stack in the terminal. First run stack setup to setup stack. Next run stack build to build the project. This will build the project. Now run stack build intero to setup Intero for the project. This will allow Haskero to work correctly. Finally run code . to load up the project in Visual Studio Code. Haskero should now be working correctly. If Haskero is having issues finding stack then you’ll need to make sure that stack is on the system path (or mess with the Haskero configuration so that it has the correct location to run stack from). You can use the command stack build --exec MyFirstHaskellProject to compile and then run the built executable.

Looking around the newly created project

In the project you should see a few files & directories have been created for you. MyFirstHaskellProject.cabal & stack.yaml are filled with settings used when building the project. app/Main.hs is the Haskell file containing the entry point of the application. The src & test directories are to contain source code and test code respectively.

Future projects

Here’s a list of what you need to do in the future when starting a new project.

  1. Run stack new MyFirstHaskellProject new-template to initialize a new project.
  2. Change directories in terminal to the new project.
  3. Run stack build to do an initial build of the project.
  4. Run stack build intero to add Intero to the project.
  5. Run code . to start Visual Studio Code with the project loaded up.

Visual Studio Code Download