# Writing prettier Haskell with Unicode Syntax and Vim

DevFeed: [Writing prettier Haskell with Unicode Syntax and Vim](<https://devfeed.tech/articles/writing-prettier-haskell-with-unicode-syntax-and-vim-27911.md>)

Original publisher: [Read original article](<http://alt-romes.github.io/posts/2023-06-21-haskell-unicode-syntax-vim.html>)

Published: 2023-06-21T00:00:00Z

Content type: tutorial

Language: en

Sources: [Romes' Musings](<https://devfeed.tech/sources/romes-musings.md>)

Topics: [Haskell](<https://devfeed.tech/topics/haskell.md>), [Vim](<https://devfeed.tech/topics/vim.md>)

Tags: [haskell](<https://devfeed.tech/tags/haskell.md>), [syntax](<https://devfeed.tech/tags/syntax.md>), [vim](<https://devfeed.tech/tags/vim.md>), [writing](<https://devfeed.tech/tags/writing.md>)

## AI overview

This tutorial explains how GHC Haskell's UnicodeSyntax extension lets programmers use Unicode symbols for selected keywords and identifiers. It also shows how Vim digraphs provide convenient two-key input for Unicode symbols, with examples of common Haskell notation and configuration options.

## Source excerpt

Contents 1 Haskell's Unicode Syntax Extension 2 Digraphs in Vim 3 Conclusion 1 Haskell's Unicode Syntax Extension Haskell (well, GHC Haskell) features an extension called UnicodeSyntax. When enabled, this extension allows the use of certain unicode symbols in place of their corresponding keywords. A great example is the forall keyword being equivalent to the unicode symbol ∀, the two of which can be used interchangebly when UnicodeSyntax is enabled. Furthermore, with Haskell being a unicode-friendly language, one can define common Haskell functions, operators or type variables using unicode symbols - which doesn't even require UnicodeSyntax to be enabled. For example, one can define the predicate ∈ on lists as an alias for elem as follows: -- 5 ∈ [1,3,5] == True (∈) :: ∀ α. Eq α => α -> [α] -> Bool (∈) = elem In practice, I use just a handful of unicode symbols both as keywords and as identifiers, but a mostly comprehensive list of the keywords that have unicode alternatives is presented in the GHC user's guide UnicodeSyntax extension page. Specifically, in most of my programs you can be sure to find the following: ∀ instead of forall, which is faster to input than the whole word. A lot of unicode type variables, α, β, τ, σ, δ, κ, ρ - they are really easy to type too. ⊸ instead of %1 ->, to use the so-called "lollipop" notation for linear functions. In my opinion, those are low-hanging niceties (with vim) that make the program look better overall, but there are others that I haven't yet reached for which you may still find good/useful. For example, there's a library in hackage, containers-unicode-symbols, which exposes multiple unicode variants of functions on containers (Maps,Sets,...) such as ∈,∉,∅,∪,∩,⊆,⊈. Finally, I usually add default-extensions: UnicodeSyntax to my cabal file to make the extension available by default on all modules. However, you can also enable it on a per module basis as usual with {-# LANGUAGE UnicodeSyntax #-} at the top of the module. 2 Dig