Reorganise Haskell snippets

This commit is contained in:
Louis Pilfold 2015-11-28 00:50:02 +00:00
parent c62240a433
commit b5ab96b6a5
2 changed files with 10 additions and 73 deletions

View File

@ -1,68 +0,0 @@
priority -50
snippet if "if ... then ... else ..."
if ${1:condition}
then ${2:expression}
else ${3:expression}
endsnippet
snippet case "case ... of ..."
case ${1:expression} of
${2:pattern} -> ${3:expression}
${4:pattern} -> ${5:expression}
endsnippet
snippet :: "Type signature"
${1:name} :: ${2:Type} -> ${3:Type}
endsnippet
snippet => "Type constraint"
(${1:Class} ${2:a}) => $2
endsnippet
snippet def "Function definition"
${1:name} :: ${2:Type} -> ${3:Type}
endsnippet
snippet def[] "Function definition for list patterns"
${1:name} :: [${2:Type}] -> ${3:Type}
$1 [] = ${4:undefined}
$1 ${5:(x:xs)} = ${6:undefined}
endsnippet
snippet = "Function clause"
${1:name} ${2:pattern} = ${3:undefined}
endsnippet
snippet 2= "Function clause"
${1:name} ${2:pattern} = ${3:undefined}
$1 ${4:pattern} = ${5:undefined}
endsnippet
snippet 3= "Function clause"
${1:name} ${2:pattern} = ${3:undefined}
$1 ${4:pattern} = ${5:undefined}
$1 ${6:pattern} = ${7:undefined}
endsnippet
snippet | "Guard"
| ${1:predicate} = ${2:undefined}
endsnippet
snippet \ "Lambda expression"
\\${1:pattern} -> ${2:expression}
endsnippet
snippet [|] "List comprehension"
[${3:foo }$1 | ${1:x} <- ${2:xs} ]
endsnippet
snippet let "let ... in ..."
let ${1:name} = ${2:expression}
in ${3:expression}
endsnippet
snippet wh "where x = expression"
where
${1:name} = ${2:expression}
endsnippet

View File

@ -8,7 +8,7 @@ snippet inline
{-# INLINE ${0:name} #-}
snippet info
-- |
-- Module : ${1:Module.Namespace}
-- Module : ${1:`substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')`}
-- Copyright : ${2:Author} ${3:2011-2012}
-- License : ${4:BSD3}
--
@ -43,8 +43,11 @@ snippet class
snippet module
module `substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` (
) where
`expand('%') =~ 'Main' ? "\n\nmain = do\n print \"hello world\"" : ""`
`expand('%') =~ 'a' ? "\nmain :: IO ()\nmain = undefined" : ""`
snippet main
main :: IO ()
main = ${0:undefined}
snippet const
${1:name} :: ${2:a}
$1 = ${0:undefined}
@ -54,11 +57,13 @@ snippet fn
snippet fn2
${1:fn} :: ${2:a} -> ${3:a} -> ${4:a}
$1 ${5} = ${0:undefined}
snippet fn3
${1:fn} :: ${2:a} -> ${3:a} -> ${4:a} -> ${5:a}
$1 ${6} = ${0:undefined}
snippet => "Type constraint"
(${1:Class} ${2:a}) => $2
snippet ap
${1:map} ${2:fn} ${0:list}
snippet do
do
snippet \
\\${1:x} -> ${0:expression}
snippet (\