Skip to content
Emacs YASnippet snippets for Haskell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
LICENSE initial commit May 25, 2011
README.md updated README for separator snippet May 30, 2011
case.yasnippet initial commit May 26, 2011
class.yasnippet
comprehension.yasnippet initial commit May 26, 2011
data.yasnippet
data_braced.yasnippet initial commit May 26, 2011
data_family.yasnippet initial commit May 26, 2011
data_instance.yasnippet
definition.yasnippet initial commit May 26, 2011
definition_guarded.yasnippet
deriving.yasnippet
deriving_all.yasnippet initial commit May 26, 2011
gadt.yasnippet
hiding.yasnippet initial commit May 26, 2011
if.yasnippet
import.yasnippet initial commit May 26, 2011
import_qualified.yasnippet initial commit May 26, 2011
instance.yasnippet initial commit May 26, 2011
lambda.yasnippet initial commit May 26, 2011
let.yasnippet initial commit May 26, 2011
main.yasnippet initial commit May 26, 2011
module.yasnippet initial commit May 26, 2011
newtype.yasnippet initial commit May 26, 2011
newtype_braced.yasnippet initial commit May 26, 2011
pragma.yasnippet
pragma_language.yasnippet initial commit May 26, 2011
separator.yasnippet
triple.yasnippet initial commit May 26, 2011
tuple.yasnippet
type.yasnippet initial commit May 26, 2011
undefined.yasnippet initial commit May 26, 2011
where.yasnippet
xxs.yasnippet initial commit May 26, 2011

README.md

HSnippets :: Emacs YASnippet snippets for Haskell

YASnippet is a template system for Emacs. It allows you to type an abbreviation and automatically expand it into function templates.

HSnippets is designed for use with haskell-indentation-mode, i.e. it does not do any indentation itself, but relies on the mode (or the user) to do so. Also note that the snippets never add any unnecessary lines to the code listing, only the lines taken up by the snippet itself, leaving the user to manage empty space themselves.

As a convenience, fields are undefined where possible/meaningful, so that you can skip fields, compile the code to type check it, and come back and fill them in later. Where types are expected, T is often the default. When I'm working I like to put data T = T deriving (Show) at the top of the file, so that I can skip some of those and fill them in later as well.

I highly recommend you do something like the following in your emacs file

(require 'yasnippet)
(setq yas/trigger-key "<C-tab>") ;; make sure this is before yas/initialize
(yas/initialize)
(yas/load-directory (concat site-lisp "snippets"))

Having the trigger-key as C-tab works out much better, because then the tab key will only be used for both haskell indentation, and cycling through yas fields, but not to trigger expansions. For example, if your point were at # below, hitting tab would re-indent (as desired) instead of expanding the 'where' snippet.

foo :: Foo -> Foo
foo x = bar x y
where#

The Snippets

  • name [^note] : 'key'
  • case : 'case'
  • class : 'class'
  • comprehension : '|'
  • data : 'data'
  • data_braced : 'datab'
  • data_family : 'dataf'
  • data_instance : 'datai'
  • definition ^1 : '='
  • definition_guarded ^1 : '|='
  • deriving : 'dv'
  • deriving_all : 'dva'
  • gadt : 'gadt'
  • hiding : 'hd'
  • if : 'if'
  • import : 'imp'
  • import_qualified : 'impq'
  • instance : 'inst'
  • lambda ^2 : '\'
  • let : 'let'
  • main : 'main'
  • module : 'mod'
  • newtype : 'new'
  • newtype_braced : 'newb'
  • pragma : 'prag'
  • pragma_language : 'lang'
  • separator : 'sep'
  • tuple : ','
  • triple : ',,'
  • type : 'type'
  • undefined : 'un'
  • where ^1 : 'where'
  • xxs : 'xxs'

Notes

Some things I couldn't get working. Any help/tips appreciated.

  1. I could only get the definition snippets to indent properly at the top level by breaking indentation if nested, and vice versa, so i chose to break them if nested. Use the where snippet if you want a nested definition with a type declaration.

  2. For some reason the lambda snippet does not work on my system if the key is the first character on the line. Since this should never happen in normal code, it shouldn't matter. Just a heads up.

Something went wrong with that request. Please try again.