Haskell Mode Help
Name:Haskell Mode
Version:0.1.1
Last update:2021-03-03 12:23:43





Introduction

Haskell Mode is a mode for the text editor Alpha: it installs basic support for editing Haskell program files using Alpha. Literate Haskell files (with .lhs extension) are also supported.
This mode provides the following features: Click on this Haskell Example link for an example syntax file.

Editing in Haskell mode

There are several ways of editing a file in Haskell mode:

Completions

There are two aspects regarding word completion in Haskell mode: The structure keywords recognized by the Haskell mode are: case, data, if, let, module.

File marking

The Marks popup (📖) lets you mark the definition of functions preceded by a function type declaration. For instance, the following two lines:
foo :: (Num a) => a -> a -> a
foo x y = 2*x+3*y
will result in the function 'foo' to be marked.

Declarations parsing

The Parse popup (⚙) lets you mark all the declarations that use the class, data, import, instance, newtype, and type keywords. This is automatic: just open the Parse popup (⚙) found in the control bar of the document window.

Console

Haskell mode also features a console to interact with the ghci command from Alpha. You can activate Alpha's Haskell console with 'Command-K' (if Alpha is in Haskell mode) or via the Launch Console menu item in the Haskell menu. To launch the console without necessarily being in Haskell mode, you can also activate the Console Launcher package (from Alpha ↣ Global Settings ↣ Features). This inserts a Consoles submenu in the Tools menu. Then select Haskell from this submenu.
Here is an example of code executed from Alpha's Haskell console:
-- Welcome to Alpha's Haskell console.
-- Running ghc 8.6.5.
λ> :show imports
import Prelude -- implicit
λ> map (+3) [2,6,7,1]
[5,9,10,4]
λ> :info filter
filter :: (a -> Bool) -> [a] -> [a] 	-- Defined in ‘GHC.List’
λ> filter even [1..10]
[2,4,6,8,10]
λ> 
Of course, for this to work, you must have installed the Glasgow Haskell Compiler (and in particular the ghci tool) on your machine.
This tool should be automatically detected by Alpha. If this is not the case, use the Set Tool menu item in Haskell menu to set it manually.
See the Console Commands History section to learn how to browse through the commands history.

Key bindings

The following key bindings are defined in Haskell mode:

Literate Haskell

Literate Haskell files (with a .lhs extension) are also supported by Alpha's Haskell mode. For this kind of files, the Haskell menu contains the following additional items :
Insert Code Environment
This command is suitable for Latex-style literate programming. It lets you insert a \begin{code}...\end{code} environment. If there is a selection, it is wrapped in the environment.
Insert '>' Prefix
This command is suitable for Bird-style literate programming. It lets you insert a '> ' prefix at the beginning of the selected lines.
Remove '>' Prefix
This command appears when you open the menu and press the Option key (). It removes the '> ' prefix found at the beginning of the selected lines.
Render Markdown
This command lets you visualize the contents of the literate Haskell file in Alpha's Markdown viewer.
Click on this Lhs Example link to display literate Haskel example files.

Known problems

Please report any problem or bug you encounter in Alpha's Bug Tracker.

License and Disclaimer

Copyright (c) 2019-2021, Bernard Desgraupes.
All rights reserved.
The Haskell Mode package is free software and distributed under the terms of the new BSD license:
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BERNARD DESGRAUPES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.