Skip to content

Improve lambda case #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion indent/haskell.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
" Filename: indent/haskell.vim
" Author: itchyny
" License: MIT License
" Last Change: 2023/11/07 19:40:39.
" Last Change: 2024/08/04 15:46:49.
" =============================================================================

if exists('b:did_indent')
Expand Down Expand Up @@ -178,6 +178,10 @@ function! GetHaskellIndent() abort
return match(line, '\v^\s*%(<where>|.*<let>)?\s*\zs') + &shiftwidth
endif

if line =~# '\v\\\s*<case>\s*[[:alnum:](\-\"''\[]'
return match(line, '\v\\\s*<case>\s*\zs\S')
endif

if nonblankline =~# '\v^.*[^|]\|[^|].*\='
return s:after_guard()
endif
Expand Down
6 changes: 6 additions & 0 deletions test/case/lambda_case_literal.in.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
f = \case [] -> 0
"one" -> 1
'0':_ -> 0
xs@('-':_) -> g $ read xs
where g = \case -1 -> -100
_ -> -1
6 changes: 6 additions & 0 deletions test/case/lambda_case_literal.out.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
f = \case [] -> 0
"one" -> 1
'0':_ -> 0
xs@('-':_) -> g $ read xs
where g = \case -1 -> -100
_ -> -1
5 changes: 5 additions & 0 deletions test/case/lambda_case_same_line.in.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
f = \case 1 -> 0
2 -> 1
x -> g x
where g = \ case -1 -> -1
_ -> 3
5 changes: 5 additions & 0 deletions test/case/lambda_case_same_line.out.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
f = \case 1 -> 0
2 -> 1
x -> g x
where g = \ case -1 -> -1
_ -> 3
Loading