├── .github └── workflows │ └── ci.yaml ├── .gitignore ├── LICENSE ├── README.md ├── indent └── haskell.vim └── test ├── case ├── case.in.hs ├── case.out.hs ├── case_guard.in.hs ├── case_guard.out.hs ├── case_let_in.in.hs ├── case_let_in.out.hs ├── case_same_line.in.hs ├── case_same_line.out.hs ├── case_same_line_parenthesis.in.hs ├── case_same_line_parenthesis.out.hs ├── caseif.in.hs ├── caseif.out.hs ├── disable_case.in.hs ├── disable_case.out.hs ├── disable_case_case_let_in.in.hs ├── disable_case_case_let_in.out.hs ├── disable_case_caseif.in.hs ├── disable_case_caseif.out.hs ├── disable_case_where_case.in.hs ├── disable_case_where_case.out.hs ├── lambda_case.in.hs ├── lambda_case.out.hs ├── lambda_case_literal.in.hs ├── lambda_case_literal.out.hs ├── lambda_case_same_line.in.hs ├── lambda_case_same_line.out.hs ├── where_case.in.hs └── where_case.out.hs ├── class ├── class.in.hs ├── class.out.hs ├── class_where.in.hs └── class_where.out.hs ├── comment ├── after_module_where.in.hs ├── after_module_where.out.hs ├── after_where.in.hs ├── after_where.out.hs ├── before_blank_line_and_class.in.hs ├── before_blank_line_and_class.out.hs ├── before_class.in.hs ├── before_class.out.hs ├── before_data.in.hs ├── before_data.out.hs ├── before_instance.in.hs ├── before_instance.out.hs ├── block_comment.in.hs ├── block_comment.out.hs ├── block_comment_where.in.hs ├── block_comment_where.out.hs ├── class_comments.in.hs ├── class_comments.out.hs ├── double_block_comments.in.hs ├── double_block_comments.out.hs ├── line_comments.in.hs ├── line_comments.out.hs ├── list.in.hs ├── list.out.hs ├── module_comments.in.hs ├── module_comments.out.hs ├── module_lines_comments.in.hs ├── module_lines_comments.out.hs ├── splitter.in.hs ├── splitter.out.hs ├── top_level_block_comment.in.hs └── top_level_block_comment.out.hs ├── datatype ├── after_deriving.in.hs ├── after_deriving.out.hs ├── after_deriving_lines.in.hs ├── after_deriving_lines.out.hs ├── after_deriving_lines_comma_first.in.hs ├── after_deriving_lines_comma_first.out.hs ├── after_deriving_parenthesis.in.hs ├── after_deriving_parenthesis.out.hs ├── datatype.in.hs ├── datatype.out.hs ├── datatype_eq.in.hs ├── datatype_eq.out.hs ├── enter_enter.in.hs ├── enter_enter.out.hs ├── gadt.in.hs ├── gadt.out.hs ├── multiple.in.hs ├── multiple.out.hs ├── multiple_type.in.hs ├── multiple_type.out.hs ├── no_newline.in.hs ├── no_newline.out.hs ├── reindent.in.hs ├── reindent.out.hs ├── type_family.in.hs └── type_family.out.hs ├── do ├── do_enter_enter.in.hs ├── do_enter_enter.out.hs ├── do_same_line.in.hs ├── do_same_line.out.hs ├── double_do.in.hs ├── double_do.out.hs ├── let_do.in.hs ├── let_do.out.hs ├── main_do.in.hs ├── main_do.out.hs ├── main_do_sw4.in.hs ├── main_do_sw4.out.hs ├── main_do_sw8.in.hs ├── main_do_sw8.out.hs ├── where_do.in.hs └── where_do.out.hs ├── function ├── function.in.hs ├── function.out.hs ├── function_break_line.in.hs ├── function_break_line.out.hs ├── function_break_lines.in.hs ├── function_break_lines.out.hs ├── function_eq_first.in.hs ├── function_eq_first.out.hs ├── function_eq_last.in.hs ├── function_eq_last.out.hs ├── function_eq_last_after.in.hs ├── function_eq_last_after.out.hs ├── where_function_eq_first.in.hs └── where_function_eq_first.out.hs ├── guard ├── case_guard.in.hs ├── case_guard.out.hs ├── guard.in.hs ├── guard.out.hs ├── instance_guard.in.hs ├── instance_guard.out.hs ├── noindent.in.hs ├── noindent.out.hs ├── or.in.hs ├── or.out.hs ├── reindent.in.hs ├── reindent.out.hs ├── top_of_line.in.hs ├── top_of_line.out.hs ├── where_case_guard.in.hs ├── where_case_guard.out.hs ├── where_same_line.in.hs ├── where_same_line.out.hs ├── where_sameline_guard.in.hs ├── where_sameline_guard.out.hs ├── where_top_of_line.in.hs └── where_top_of_line.out.hs ├── if ├── guard.in.hs ├── guard.out.hs ├── ifthen.in.hs ├── ifthen.out.hs ├── ifthen_sameline.in.hs ├── ifthen_sameline.out.hs ├── ifthendo.in.hs ├── ifthendo.out.hs ├── ifthenelse_nested.in.hs └── ifthenelse_nested.out.hs ├── infix ├── infix.in.hs └── infix.out.hs ├── instance ├── instance.in.hs ├── instance.out.hs ├── instance_elements.in.hs ├── instance_elements.out.hs ├── instance_newline.in.hs ├── instance_newline.out.hs ├── instance_newline_2.in.hs ├── instance_newline_2.out.hs ├── instance_no_where.in.hs ├── instance_no_where.out.hs ├── instance_where.in.hs ├── instance_where.out.hs ├── multiple_instance.in.hs ├── multiple_instance.out.hs ├── multiple_instance_no_where.in.hs └── multiple_instance_no_where.out.hs ├── let ├── let.in.hs ├── let.out.hs ├── let_in_let_in.in.hs ├── let_in_let_in.out.hs ├── let_in_same_line.in.hs ├── let_in_same_line.out.hs ├── let_let.in.hs ├── let_let.out.hs ├── let_monad.in.hs └── let_monad.out.hs ├── list ├── arg_list.in.hs ├── arg_list.out.hs ├── arg_tuple.in.hs ├── arg_tuple.out.hs ├── comprehension_multi_line.in.hs ├── comprehension_multi_line.out.hs ├── comprehension_multi_line2.in.hs ├── comprehension_multi_line2.out.hs ├── comprehension_multi_line3.in.hs ├── comprehension_multi_line3.out.hs ├── comprenesion.in.hs ├── comprenesion.out.hs ├── list.in.hs ├── list.out.hs ├── list_parenthesis.in.hs ├── list_parenthesis.out.hs ├── multi.in.hs ├── multi.out.hs ├── multi_comma.in.hs └── multi_comma.out.hs ├── macro ├── guard.in.hs ├── guard.out.hs ├── macro.in.hs ├── macro.out.hs ├── module_export.in.hs ├── module_export.out.hs ├── module_export_with_comment.in.hs └── module_export_with_comment.out.hs ├── module ├── export.in.hs ├── export.out.hs ├── export_comma_first.in.hs ├── export_comma_first.out.hs ├── export_lines.in.hs ├── export_lines.out.hs ├── export_lines_enter.in.hs ├── export_lines_enter.out.hs ├── export_lines_enter_paren.in.hs ├── export_lines_enter_paren.out.hs ├── export_lines_paren_where.in.hs ├── export_lines_paren_where.out.hs ├── export_lines_where.in.hs ├── export_lines_where.out.hs ├── export_module.in.hs ├── export_module.out.hs ├── export_module_comment.in.hs ├── export_module_comment.out.hs ├── export_module_comment_with_line_comment.in.hs ├── export_module_comment_with_line_comment.out.hs ├── import_comma_first.in.hs ├── import_comma_first.out.hs ├── module.in.hs └── module.out.hs ├── parenthesis ├── after_let.in.hs ├── after_let.out.hs ├── backtick_last.in.hs ├── backtick_last.out.hs ├── closed_binding.in.hs ├── closed_binding.out.hs ├── closing_parenthesis.in.hs ├── closing_parenthesis.out.hs ├── let_parenthesis.in.hs ├── let_parenthesis.out.hs ├── open_parenthesis.in.hs ├── open_parenthesis.out.hs ├── open_parenthesis_tuple.in.hs ├── open_parenthesis_tuple.out.hs ├── operator_definition.in.hs ├── operator_definition.out.hs ├── operator_last.in.hs ├── operator_last.out.hs ├── operator_type_annotation.in.hs ├── operator_type_annotation.out.hs ├── where.in.hs ├── where.out.hs ├── where_guard.in.hs └── where_guard.out.hs ├── pragma ├── indented.in.hs ├── indented.out.hs ├── inline.in.hs ├── inline.out.hs ├── pragma.in.hs ├── pragma.out.hs ├── toplevel.in.hs ├── toplevel.out.hs ├── unpack.in.hs └── unpack.out.hs ├── recordtype ├── after_deriving.in.hs ├── after_deriving.out.hs ├── after_deriving_lines.in.hs ├── after_deriving_lines.out.hs ├── after_deriving_lines_comma_first.in.hs ├── after_deriving_lines_comma_first.out.hs ├── after_deriving_parenthesis.in.hs ├── after_deriving_parenthesis.out.hs ├── coomma_first_after_deriving_lines_comma_first.in.hs ├── coomma_first_after_deriving_lines_comma_first.out.hs ├── eq_first.in.hs ├── eq_first.out.hs ├── newline_record.in.hs ├── newline_record.out.hs ├── no_newline.in.hs ├── no_newline.out.hs ├── record.in.hs ├── record.out.hs ├── record_newline.in.hs ├── record_newline.out.hs ├── record_newline_deriving.in.hs └── record_newline_deriving.out.hs ├── test.vim ├── typesig ├── typesig.in.hs └── typesig.out.hs └── where ├── after_guard.in.hs ├── after_guard.out.hs ├── block.in.hs ├── block.out.hs ├── multiple.in.hs ├── multiple.out.hs ├── multiple_after_guard.in.hs ├── multiple_after_guard.out.hs ├── no_newline_same_line.in.hs ├── no_newline_same_line.out.hs ├── no_newline_where.in.hs ├── no_newline_where.out.hs ├── reindent.in.hs ├── reindent.out.hs ├── reindent_far.in.hs ├── reindent_far.out.hs ├── unindent.in.hs ├── unindent.out.hs ├── unindent_multiple.in.hs ├── unindent_multiple.out.hs ├── where.in.hs ├── where.out.hs ├── where_eq_newline.in.hs ├── where_eq_newline.out.hs ├── where_paren.in.hs └── where_paren.out.hs /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | 9 | jobs: 10 | test: 11 | name: Test 12 | runs-on: ubuntu-latest 13 | strategy: 14 | matrix: 15 | vim: 16 | - v8.2.0000 17 | - v8.1.0000 18 | - v8.0.0000 19 | - v7.4 20 | steps: 21 | - name: Checkout code 22 | uses: actions/checkout@v3 23 | - name: Checkout vim-themis 24 | uses: actions/checkout@v3 25 | with: 26 | repository: thinca/vim-themis 27 | path: vim-themis 28 | - name: Setup Vim 29 | uses: rhysd/action-setup-vim@v1 30 | id: vim 31 | with: 32 | version: ${{ matrix.vim }} 33 | - name: Test 34 | env: 35 | THEMIS_VIM: ${{ steps.vim.outputs.executable }} 36 | run: ./vim-themis/bin/themis --reporter spec 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /doc/tags 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2023 itchyny 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vim-haskell-indent [![CI Status](https://github.com/itchyny/vim-haskell-indent/workflows/CI/badge.svg)](https://github.com/itchyny/vim-haskell-indent/actions) 2 | ## The best indent plugin for Haskell in Vim 3 | 4 | ![vim-haskell-indent](https://raw.githubusercontent.com/wiki/itchyny/vim-haskell-indent/image/1.gif) 5 | 6 | ![vim-haskell-indent](https://raw.githubusercontent.com/wiki/itchyny/vim-haskell-indent/image/2.gif) 7 | 8 | ![vim-haskell-indent](https://raw.githubusercontent.com/wiki/itchyny/vim-haskell-indent/image/3.gif) 9 | 10 | ## Installation 11 | Install with your favorite plugin manager. 12 | 13 | ## Author 14 | itchyny (https://github.com/itchyny) 15 | 16 | ## License 17 | This software is released under the MIT License, see LICENSE. 18 | -------------------------------------------------------------------------------- /indent/haskell.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " Filename: indent/haskell.vim 3 | " Author: itchyny 4 | " License: MIT License 5 | " Last Change: 2025/04/15 08:09:38. 6 | " ============================================================================= 7 | 8 | if exists('b:did_indent') 9 | finish 10 | endif 11 | 12 | let b:did_indent = 1 13 | 14 | setlocal indentexpr=GetHaskellIndent() 15 | setlocal indentkeys=!^F,o,O,=wher,=deri,==,0=in,0=class,0=instance,0=data,0=type,0=else,0=then,0,0},0],0(,0),0#,0,0== 16 | 17 | let s:save_cpo = &cpo 18 | set cpo&vim 19 | 20 | function! GetHaskellIndent() abort 21 | 22 | let line = getline(v:lnum) 23 | 24 | " comment 25 | if s:in_comment() 26 | let i = s:indent_comment() 27 | if i >= 0 28 | return i 29 | endif 30 | endif 31 | 32 | " #if, #else, #endif, #include 33 | if line =~# '\v^\s*%(#$|#\s*\w+)' 34 | return 0 35 | endif 36 | 37 | " where 38 | if line =~# '\v' 39 | let i = s:indent_where() 40 | if i >= 0 41 | return i 42 | endif 43 | endif 44 | 45 | " deriving 46 | if line =~# '\v^\s*' 47 | if line =~# '\v^\s*}\s*deri%[ving]>' 48 | return s:indent_parenthesis() 49 | endif 50 | return s:indent('\v', '\v^.*.*\zs\=', 0) 51 | endif 52 | 53 | " class, instance 54 | if line =~# '\v^\s*<%(class|instance)>' 55 | return 0 56 | endif 57 | 58 | " then 59 | if line =~# '\v^\s*' 60 | return s:indent_then() 61 | endif 62 | 63 | " else 64 | if line =~# '\v^\s*' 65 | return s:indent_else() 66 | endif 67 | 68 | " | 69 | if line =~# '\v^\s*\||\|\s*%(--.*)?$' 70 | return s:indent_bar() 71 | endif 72 | 73 | " in 74 | if line =~# '\v^\s*' 75 | return s:indent('\v^\s*', '\v^.*\s*\zs', 0, -1) 76 | endif 77 | 78 | " = 79 | if line =~# '\v^\s*\=' 80 | return s:indent_eq() 81 | endif 82 | 83 | if line =~# '\v\=' 84 | if getline(v:lnum - 1) =~# '\v^\s*-\>' 85 | return indent(v:lnum - 1) - &shiftwidth 86 | endif 87 | endif 88 | 89 | " }, ], ) 90 | if line =~# '\v^\s*[})\]]' 91 | return s:indent_parenthesis() 92 | endif 93 | 94 | if s:prevnonblank(v:lnum - 1) == 0 95 | return 0 96 | endif 97 | 98 | let nonblankline = getline(s:prevnonblank(v:lnum - 1)) 99 | 100 | " data, type 101 | if line =~# '\v^\s*<%(data|type)>' && nonblankline !~# '\v<%(class|instance)>.*' 102 | return 0 103 | endif 104 | 105 | let noparen = '[^()[\]{}]' 106 | let noparen = '%(' . noparen . '+|\(' . noparen . '*\)|\[' . noparen . '*\])' 107 | let noparen = '%(' . noparen . '+|\(' . noparen . '*\)|\[' . noparen . '*\])*' 108 | 109 | if line =~# '\v^\s*,' . noparen . '\s*%(--.*)?$' && nonblankline =~# '\v^\s*,' 110 | return match(nonblankline, '^\s*\zs,') 111 | endif 112 | 113 | let line = getline(v:lnum - 1) 114 | 115 | " #if, #else, #endif, #include 116 | if nonblankline =~# '^\s*#' 117 | return 0 118 | endif 119 | 120 | if nonblankline =~# '^\s*--' 121 | return match(nonblankline, '^\s*\zs--') 122 | endif 123 | 124 | if nonblankline =~# '\v^\s*' 125 | return match(nonblankline, '\S') 126 | endif 127 | 128 | if nonblankline =~# '\v^\s*.*\=\>\s*%(--.*)?$' 129 | return match(nonblankline, '\v^\s*\zs') + &shiftwidth 130 | endif 131 | 132 | if nonblankline =~# '\v\s*%(--.*)?$' 133 | return match(nonblankline, '\v^\s*%(|.*)?\s*\zs') + &shiftwidth 134 | endif 135 | 136 | if nonblankline =~# '\v\s*[[:alnum:](]' 137 | return match(nonblankline, '\v.*\s*\zs') 138 | endif 139 | 140 | if line =~# '\v' && line !~# '\v^\s*#' 141 | if line !~# '\v' 142 | return match(line, '\v.*\s*\zs') 143 | elseif line !~# '\v' 144 | return match(line, '\v.*\zs') 145 | endif 146 | endif 147 | 148 | if line =~# '\v.*.*\s*%(--.*)?$' && line !~# '^\s*#' 149 | if get(g:, 'haskell_indent_disable_case', 0) 150 | if line =~# '\v^\s*' 151 | return match(line, '\v^\s*%()?\s*\zs') + &shiftwidth 152 | else 153 | return indent(s:prevnonblank(v:lnum - 1)) + &shiftwidth 154 | endif 155 | else 156 | return line =~# '\v.*\s*([[:alnum:](\"''\[]|-\d)' 157 | \ ? match(line, '\v.*\s*\zs\S') 158 | \ : match(line, '\v.*\s*\zs') 159 | endif 160 | endif 161 | 162 | if line =~# '\v\\case\s*%(--.*)?$' 163 | return match(line, '\v^\s*%(|.*)?\s*\zs') + &shiftwidth 164 | endif 165 | 166 | if line =~# '\v\\\s*\s*[[:alnum:](\-\"''\[]' 167 | return match(line, '\v\\\s*\s*\zs\S') 168 | endif 169 | 170 | if nonblankline =~# '\v^\s*}?' . noparen . '[([{]' . noparen . '[-+/*\$&<>,]?\s*%(--.*)?$' 171 | if nonblankline =~# '\v[([{]\s*%(--.*)?$' 172 | return match(nonblankline, '\v^\s*%(|.*)?\s*\zs') + &shiftwidth 173 | elseif nonblankline =~# '\v[-+/*\$&<>,]\s*%(--.*)?$' 174 | return match(nonblankline, '\v^\s*}?' . noparen . '%(\[.*\|\s*\zs|[([{]\s*\zs)') 175 | elseif nonblankline =~# '\v^[^[\]]*\[([^[\]]*|\[[^[\]]*\])*\|%([^[\]]*|\[[^[\]]*\])*\s*%(--.*)?$' 176 | return match(nonblankline, '\v^[^[\]]*\[%([^[\]]*|\[[^[\]]*\])*\zs\|') 177 | else 178 | return match(nonblankline, '\v^\s*}?' . noparen . '\zs[([{]') 179 | endif 180 | endif 181 | 182 | " ( 183 | if getline(v:lnum) =~# '\v^\s*\(' 184 | let lnum = s:prevnonblank(v:lnum - 1) 185 | if lnum == 0 186 | return -1 187 | elseif nonblankline =~# '\v^\s*%(|.*).*%([-+/*\$&<>=,]+|`\k+`)\s*%(--.*)?$' 188 | return match(nonblankline, '\v^\s*<%(where|let)>\s*\zs') + &shiftwidth 189 | elseif nonblankline =~# '\v^\s*<%(where|let)>' 190 | return match(nonblankline, '\v^\s*%(|)?\s*\zs') 191 | elseif nonblankline =~# '\v^\s*' 192 | return indent(lnum) + &shiftwidth 193 | endif 194 | endif 195 | 196 | if nonblankline =~# '\v' 197 | return s:indent('', '\v^\s*\zs', 0) 198 | endif 199 | 200 | if nonblankline =~# '\v^.*[^|]\|[^|].*\=' 201 | return s:after_guard() 202 | endif 203 | 204 | if nonblankline =~# '\v[)}\]]\s*%(--.*)?$' 205 | let i = s:unindent_after_parenthesis(s:prevnonblank(v:lnum - 1), match(nonblankline, '\v[)}\]]\s*%(--.*)?$')) 206 | if i >= 0 207 | return i 208 | endif 209 | endif 210 | 211 | if nonblankline =~# '\v^\s*\|\s*.*\<-\s*.*,\s*%(--.*)?$' 212 | return match(nonblankline, '\v^\s*\|\s*\zs.*\<-\s*.*,\s*%(--.*)?$') 213 | endif 214 | 215 | if nonblankline =~# '\v([-+/*\$&<>=,]+|`\k+`)\s*%(--.*)?$' 216 | if nonblankline =~# '\v^\s*.*,\s*%(--.*)?$' 217 | return match(nonblankline, '\S') 218 | else 219 | return match(nonblankline, '\v^\s*%(|.*)?\s*\zs') + 220 | \ (nonblankline =~# '\v%(|)|^\s*\k+\s*'. noparen .'\=.*%([-+/*\$&<>]|`\k+`)\s*%(--.*)?$|%(\=|-\>)\s*%(--.*)?$' ? &shiftwidth : 0) 221 | endif 222 | endif 223 | 224 | if nonblankline =~# '\v' 225 | return s:after_where() 226 | endif 227 | 228 | if nonblankline =~# '\v' && nonblankline !~# '\v,\s*%(--.*)?$' && indent(s:prevnonblank(v:lnum - 1)) < &shiftwidth 229 | return &shiftwidth 230 | endif 231 | 232 | if nonblankline =~# '\v' 233 | let i = s:prevnonblank(v:lnum - 1) 234 | while i 235 | let line = getline(i) 236 | if getline(i) =~# '\v' 237 | if getline(i) =~# '\v^\s*_\s*-\>' 238 | let nonblankline = getline(i) 239 | break 240 | endif 241 | return match(line, '\v^\s*\zs') 242 | endif 243 | let i -= 1 244 | endwhile 245 | endif 246 | 247 | if nonblankline =~# '\v-\>' && line =~# '\v^\s*%(--.*)?$' || nonblankline =~# '\v^\s*_\s*-\>' 248 | let i = s:prevnonblank(v:lnum - 1) 249 | while i 250 | let line = getline(i) 251 | if getline(i) =~# '\v' 252 | return match(line, '\v^\s*%(where\s+)?\zs') 253 | endif 254 | let i -= 1 255 | endwhile 256 | endif 257 | 258 | if nonblankline =~# '\v^\s*.*\=' 259 | if nonblankline =~# '\v\{-#\s*UNPACK\s*#-}' && getline(v:lnum) =~# '\v^\s*\{-#\s*UNPACK\s*#-}' 260 | return match(nonblankline, '\v\{-#\s*UNPACK\s*#-}') 261 | endif 262 | endif 263 | 264 | if nonblankline =~# '\v\s+.*\=' && nonblankline !~# '\v\s+.*\=.*' 265 | return s:indent('', getline(v:lnum) =~# '\v^\s*%(|\S+\s*\=)' ? '\v\s+\zs\S' : '\v', 0) 266 | endif 267 | 268 | " in 269 | if nonblankline =~# '\v^\s*' 270 | return s:indent('', '\v^\s*\zs.*', 0, -1) 271 | endif 272 | 273 | " :: 274 | if nonblankline =~# '\v::\s*%(--.*)?$' 275 | return indent(v:lnum - 1) + &shiftwidth 276 | endif 277 | 278 | if nonblankline =~# '::' 279 | return s:indent('', nonblankline =~# '\v,\s*%(--.*)?$' ? '\S' : '\v\{\s*\<\w+\s*::', 0, match(nonblankline, '\S')) 280 | endif 281 | 282 | if s:prevnonblank(v:lnum - 1) < v:lnum - 2 && line !~# '^\s*#' 283 | return 0 284 | elseif s:prevnonblank(v:lnum - 1) < v:lnum - 1 && line !~# '^\s*#' 285 | let i = s:prevnonblank(v:lnum - 1) 286 | let where_clause = 0 287 | let found_where = 0 288 | let indent = indent(s:prevnonblank(v:lnum - 1)) 289 | while i 290 | let line = getline(i) 291 | if substitute(line, '--.*', '', 'g') =~# '\v' 292 | let found_where = 1 293 | if indent(i) <= indent 294 | let where_clause += 1 295 | if where_clause == v:lnum - s:prevnonblank(v:lnum - 1) 296 | return match(line, '\v^.*\s*\zs') 297 | endif 298 | endif 299 | endif 300 | if 0 <= indent(i) && indent(i) < indent && line !~# '\v|^\s*\||^$' 301 | return line =~# '\v^\s*[([{]' ? indent : indent(i) 302 | endif 303 | if line =~# '\v^\s*<%(class|instance)>' && found_where 304 | return match(line, '\v^\s*<%(class|instance)>') + &shiftwidth 305 | elseif line =~# '^\S' 306 | return 0 307 | endif 308 | let i -= 1 309 | endwhile 310 | return 0 311 | endif 312 | 313 | if indent(s:prevnonblank(s:prevnonblank(v:lnum - 1) - 1)) < indent(s:prevnonblank(v:lnum - 1)) 314 | \ && nonblankline =~# '\v^\s*[-+/*$&<>=]' || getline(s:prevnonblank(s:prevnonblank(v:lnum - 1) - 1)) =~# '\v\=\s*%(--.*)?$' 315 | return indent(s:prevnonblank(s:prevnonblank(v:lnum - 1) - 1)) 316 | endif 317 | 318 | return indent(s:prevnonblank(v:lnum - 1)) 319 | 320 | endfunction 321 | 322 | " prevnonblank with skipping macros 323 | function! s:prevnonblank(lnum) abort 324 | let i = a:lnum 325 | while i > 0 326 | let i = prevnonblank(i) 327 | if getline(i) !~# '\v^\s*#\s*\w+' 328 | return i 329 | endif 330 | let i -= 1 331 | endwhile 332 | return 0 333 | endfunction 334 | 335 | " a general indent function by searching the pattern upward 336 | function! s:indent(linepattern, pattern, diff, ...) abort 337 | let i = s:prevnonblank(v:lnum - 1) 338 | if i < v:lnum - 1 339 | return 0 340 | endif 341 | if getline(v:lnum) =~# a:linepattern 342 | while i > 0 343 | let line = getline(i) 344 | if line =~# a:pattern 345 | return match(line, a:pattern) + a:diff 346 | elseif line =~# '^\S' 347 | return a:0 ? a:1 : -1 348 | endif 349 | let i -= 1 350 | endwhile 351 | endif 352 | return -1 353 | endfunction 354 | 355 | " the cursor is in comment 356 | function! s:in_comment() abort 357 | if getline(v:lnum) =~# '^\s*--' 358 | return 1 359 | endif 360 | let start = searchpos('\v%(--.*)@\s*%(--.*)?$' 372 | let name = matchstr(getline(v:lnum + 1), '\v^\s*"\zs\k+\ze%(/\k+)*"') 373 | if name !=# '' 374 | let i = v:lnum - 1 375 | while i 376 | if getline(i) =~# '\v^\s*%(where\s+)?<' . name . '>.*\=' 377 | return match(getline(i), '\v^\s*%()?\s*\zs') 378 | endif 379 | let i -= 1 380 | endwhile 381 | endif 382 | endif 383 | if getline(v:lnum) =~# '\v^\s*\{-#\s*<%(INLINE|RULES)>' 384 | return -1 385 | elseif getline(v:lnum) =~# '\v^\s*%(\{- \||\{-#.*#-}\s*%(--.*)?$|-- -{10,})' 386 | return 0 387 | endif 388 | if getline(v:lnum) =~# '^\s*[-{]-' 389 | let i = v:lnum 390 | if getline(i) =~# '^\s*--' 391 | while i <= line('$') && (getline(i) =~# '^\s*--' || getline(i) ==# '') 392 | let i += 1 393 | endwhile 394 | if getline(i) =~# '\v^\s*<%(class|instance|data)>|::.*%(-\>|-- *\^)' 395 | return match(getline(i), '^\s*\zs\S') 396 | endif 397 | endif 398 | let i = s:prevnonblank(v:lnum - 1) 399 | let previndent = 0 400 | while i > 0 401 | let line = getline(i) 402 | let indent = indent(i) 403 | if line =~# '^\s*[-{]-' 404 | return indent 405 | elseif line =~# '\v^\s*<%(class|instance)>|^\s*\s*%(--.*)?$' && line !~# '\v,\s*%(--.*)?$' 406 | return indent + &shiftwidth 407 | elseif line =~# '\v\s*\(\s*%(--.*)?$' 408 | return previndent ? previndent : indent + &shiftwidth 409 | elseif line =~# '^\S' && line !~# '^\s*#' 410 | return 0 411 | endif 412 | let previndent = indent 413 | let i -= 1 414 | endwhile 415 | endif 416 | let listpattern = '\v^\s*%(\* \@|[a-z]\)\s+|\>\s+)' 417 | if getline(v:lnum) =~# listpattern 418 | if getline(s:prevnonblank(v:lnum - 1)) =~# listpattern 419 | return indent(s:prevnonblank(v:lnum - 1)) 420 | else 421 | if getline(v:lnum) =~# '\v^\s*[a-z]\)\s+' 422 | let i = s:prevnonblank(v:lnum - 1) 423 | let indent = indent(i) 424 | while 0 < i && indent(i) == indent 425 | let i -= 1 426 | endwhile 427 | if 0 < i && getline(i) =~# '\v^\s*[a-z]\)\s+' 428 | return indent(i) 429 | endif 430 | endif 431 | return indent(s:prevnonblank(v:lnum - 1)) + &shiftwidth 432 | endif 433 | endif 434 | if getline(v:lnum - 1) =~# '\v^\s*[a-z]\)\s+' 435 | return match(getline(v:lnum - 1), '\v^\s*[a-z]\)\s+\zs') 436 | endif 437 | if getline(v:lnum) !~# '\v^\s*%(--.*)?$' && getline(s:prevnonblank(v:lnum - 1)) =~# listpattern 438 | return indent(s:prevnonblank(v:lnum - 1)) - &shiftwidth 439 | endif 440 | if getline(v:lnum) =~# '^\s*[-{]-' 441 | return 0 442 | endif 443 | let line = getline(s:prevnonblank(v:lnum - 1)) 444 | if line =~# '\v^\s*\{-#\s*%(\s+\w+,?)+' 445 | if line =~# '\v,\s*%(--.*)?$' 446 | return match(line, '\v\zs<\w+,') 447 | else 448 | return match(line, '\v\w+\s+\zs<\w+') - &shiftwidth 449 | endif 450 | endif 451 | let i = s:prevnonblank(v:lnum - 1) 452 | if i < v:lnum - 1 453 | let indent = indent(i) 454 | while 0 < i && indent(i) == indent 455 | let i -= 1 456 | endwhile 457 | if 0 < i && getline(i) =~# '\v^\s*[a-z]\)\s+' 458 | return indent(i) - &shiftwidth 459 | endif 460 | endif 461 | if getline(v:lnum) =~# '\v^\s*%(#?-}|#$)' 462 | let i = v:lnum - 1 463 | while 0 < i 464 | if getline(i) =~# '{-' 465 | return match(getline(i), '{-') 466 | endif 467 | let i -= 1 468 | endwhile 469 | endif 470 | return indent(s:prevnonblank(v:lnum - 1)) 471 | endfunction 472 | 473 | " then 474 | function! s:indent_then() abort 475 | let [lnum, col] = searchpairpos('\v', '', '\v\zs', 'bnW') 476 | if lnum == 0 && col == 0 477 | return -1 478 | else 479 | " consider adding option to decide where to indent 'then' 480 | return match(getline(lnum)[col - 1:], '\v\s*\zs') + col - 1 481 | endif 482 | endfunction 483 | 484 | " else 485 | function! s:indent_else() abort 486 | let [lnum, col] = searchpairpos('\v', '\v', '\v\zs', 'bnW') 487 | return col - 1 488 | endfunction 489 | 490 | " | 491 | function! s:indent_bar() abort 492 | if getline(v:lnum) !~# '^\s*|' 493 | return -1 494 | endif 495 | let i = s:prevnonblank(v:lnum - 1) 496 | let indent = indent(i) 497 | while i > 0 498 | let line = getline(i) 499 | if line =~# '\v^[^[\]]*%([^[\]]*|\[[^[\]]*\])*\[%([^[\]]*|\[[^[\]]*\])*%(--.*)?$' 500 | return match(line, '\v^[^[\]]*%([^[\]]*|\[[^[\]]*\])*\zs\[([^[\]]*|\[[^[\]]*\])*%(--.*)?$') + &shiftwidth 501 | elseif line =~# '\v^\s*%()?.*[^|]\|[^|].*\=' 502 | return match(line, '\v^\s*%()?.*[^|]\zs\|[^|].*\=') 503 | elseif line =~# '\v.*\=' 504 | return match(line, '\v^.*.*\zs\=') 505 | elseif line =~# '\v^\s*\s*%(--.*)?$' && indent(i) < indent || line =~# '^\S' 506 | return indent + &shiftwidth 507 | elseif line =~# '\v^\s*\s+\S' 508 | return match(line, '\v^\s*\s+\zs\S') + &shiftwidth 509 | elseif line =~# '\v[^|]\|[^|].*-\>' 510 | return match(line, '\v[^|]\zs\|[^|].*-\>') 511 | elseif line =~# '^\s*=' 512 | return match(line, '^\s*\zs=') 513 | endif 514 | let indent = indent(i) 515 | let i = s:prevnonblank(i - 1) 516 | endwhile 517 | endfunction 518 | 519 | " guard 520 | function! s:after_guard() abort 521 | let nonblankline = getline(s:prevnonblank(v:lnum - 1)) 522 | let line = getline(v:lnum - 1) 523 | if line =~# '\v^\s*%(--.*)?$' 524 | if s:prevnonblank(v:lnum - 1) < v:lnum - 2 525 | return 0 526 | endif 527 | let i = v:lnum - 1 528 | let where_clause = 0 529 | while i 530 | let line = getline(i) 531 | if line =~# '^\S' 532 | return 0 533 | endif 534 | if where_clause && line !~# '\v^\s*%(--.*)?$' && line !~# '\v^\s*\|[^|]' 535 | return match(line, '\v^\s*%()?\s*\zs') 536 | endif 537 | if line =~# '\v' 538 | let where_clause = 1 539 | endif 540 | let i -= 1 541 | endwhile 542 | endif 543 | if nonblankline =~# '\v[^|]\|\s*%(otherwise|True|0\s*\<\s*1|1\s*\>\s*0)' || getline(v:lnum) =~# '^\s*\S' 544 | let i = s:prevnonblank(v:lnum - 1) 545 | while i 546 | let line = getline(i) 547 | if line !~# '\v^\s*%(--.*)?$' && line !~# '^\s*|' 548 | return match(line, '\v^\s*%()?\s*\zs') 549 | endif 550 | let i -= 1 551 | endwhile 552 | elseif nonblankline =~# '\v^\s*.*\=' 553 | return match(line, '\v^.*.*\zs\=') 554 | else 555 | return match(line, '\v^.*[^|]\zs\|[^|].*\=') 556 | endif 557 | endfunction 558 | 559 | " = 560 | function! s:indent_eq() abort 561 | return match(getline(s:prevnonblank(v:lnum - 1)), '\v^\s*%(|)?\s*\zs') + &shiftwidth 562 | endfunction 563 | 564 | " }, ], ) 565 | function! s:indent_parenthesis() abort 566 | let view = winsaveview() 567 | execute 'normal! ' v:lnum . 'gg^' 568 | let end = getpos('.') 569 | normal! % 570 | let begin = getpos('.') 571 | call setpos('.', end) 572 | call winrestview(view) 573 | if begin[1] == end[1] 574 | return -1 575 | endif 576 | if indent(end[1] - 1) + 1 < begin[2] 577 | return match(getline(begin[1]), '\v^\s*%(|.*)?\s*\zs') 578 | endif 579 | if getline(end[1]) =~# '^\s*}' && getline(begin[1]) =~# '\v^\s+\w+\s*\{' 580 | return match(getline(begin[1]), '\v^\s+\zs') 581 | endif 582 | return begin[2] - 1 583 | endfunction 584 | 585 | " unindent after closed parenthesis 586 | function! s:unindent_after_parenthesis(line, column) abort 587 | let i = s:prevnonblank(v:lnum - 1) 588 | if i < v:lnum - 2 589 | return -1 590 | endif 591 | let pos = getpos('.') 592 | let view = winsaveview() 593 | execute 'normal! ' a:line . 'gg' . (a:column + 1) . '|' 594 | normal! % 595 | let begin = getpos('.') 596 | call setpos('.', pos) 597 | call winrestview(view) 598 | if v:lnum - 1 == begin[1] 599 | return -1 600 | endif 601 | if getline(begin[1]) =~# '\v' 602 | let i = begin[1] 603 | while i 604 | let line = getline(i) 605 | if getline(i) =~# '\v' 606 | return match(line, '\v') 607 | elseif line =~# '^\S' 608 | return 0 609 | endif 610 | let i -= 1 611 | endwhile 612 | elseif getline(begin[1]) =~# '^\s*=' 613 | return match(getline(s:prevnonblank(begin[1] - 1)), '\v^\s*%(|)?\s*\zs') 614 | elseif getline(s:prevnonblank(begin[1] - 1)) =~# '\v\=\s*%(--.*)?$' 615 | return match(getline(s:prevnonblank(begin[1] - 1)), '\v^\s*%(|)?\s*\zs') 616 | elseif getline(s:prevnonblank(begin[1] - 1)) =~# '\v' 617 | return 0 618 | endif 619 | return match(getline(begin[1]), '\v^\s*%()?\s*\zs') 620 | endfunction 621 | 622 | " where 623 | function! s:indent_where() abort 624 | if getline(v:lnum) =~# '\v^\s*' 625 | let i = s:prevnonblank(v:lnum - 1) 626 | while i > 0 627 | let line = getline(i) 628 | if line =~# '\v^\s*%()?\s*\zs\h.*\=|^\s*[^| ]' 629 | return match(line, '\v^\s*%()?\s*\zs\h.*\=|^\s*[^| ]') + &shiftwidth 630 | elseif line =~# '^\S' 631 | return -1 632 | endif 633 | let i -= 1 634 | endwhile 635 | elseif getline(v:lnum) =~# '\v^\s*\)\s*' 636 | let pos = getpos('.') 637 | let view = winsaveview() 638 | execute 'normal! ' (match(getline(v:lnum), ')') + 1) . '|%' 639 | let begin = getpos('.') 640 | call setpos('.', pos) 641 | call winrestview(view) 642 | if getline(begin[1]) =~# '\v<%(module|class|instance)>' 643 | return indent(begin[1]) + &shiftwidth 644 | elseif getline(s:prevnonblank(begin[1] - 1)) =~# '\v<%(module|class|instance)>' 645 | return indent(s:prevnonblank(begin[1] - 1)) + &shiftwidth 646 | elseif getline(begin[1]) =~# '\v^\s*\(%(--.*)?' 647 | return indent(begin[1]) 648 | endif 649 | elseif getline(v:lnum) =~# '\v^\s*<%(module|class|instance)>' 650 | return 0 651 | elseif getline(v:lnum) =~# '\v\s*%(--.*)?' 652 | let i = s:prevnonblank(v:lnum - 1) 653 | if i > 0 654 | let line = getline(i) 655 | if line =~# '\v^\s*<%(module|class|instance)>' 656 | return indent(i) + &shiftwidth 657 | endif 658 | endif 659 | endif 660 | return -1 661 | endfunction 662 | 663 | " where 664 | function! s:after_where() abort 665 | let line = getline(s:prevnonblank(v:lnum - 1)) 666 | if line =~# '\v^\s*\)\s*\s*%(--.*)?$' 667 | let pos = getpos('.') 668 | let view = winsaveview() 669 | execute 'normal! ' s:prevnonblank(v:lnum - 1) . 'gg^%' 670 | let begin = getpos('.') 671 | call setpos('.', pos) 672 | call winrestview(view) 673 | let i = getline(begin[1]) =~# '^\s*(' ? s:prevnonblank(begin[1] - 1) : begin[1] 674 | if i > 0 && getline(i) =~# '\v<%(module|class|instance)>' 675 | return 0 676 | endif 677 | endif 678 | if line =~# '\v\s*%(--.*)?$' 679 | let i = s:prevnonblank(v:lnum - 1) 680 | while i > 0 681 | let line = getline(i) 682 | if line =~# '\v^\s*' 683 | return 0 684 | elseif line =~# '\v^\s*%(||| +)' 685 | if line =~# '\v\s*%(--.*)?$' && i != s:prevnonblank(v:lnum - 1) 686 | break 687 | endif 688 | return match(line, '\v%(||| +)') + &shiftwidth 689 | elseif line =~# '\v^%(\S|\s*\k+\s*\=)' && line !~# '^--' 690 | return match(getline(s:prevnonblank(v:lnum - 1)), '\v') + &shiftwidth 691 | endif 692 | let i -= 1 693 | endwhile 694 | endif 695 | if line =~# '\v^\s*' 696 | if s:prevnonblank(v:lnum - 1) < v:lnum - 2 697 | return 0 698 | elseif s:prevnonblank(v:lnum - 1) < v:lnum - 1 699 | let i = s:prevnonblank(v:lnum - 1) - 1 700 | let indent = indent(s:prevnonblank(v:lnum - 1)) 701 | while i 702 | let line = getline(i) 703 | if line =~# '^\S' 704 | return 0 705 | elseif indent(i) < indent 706 | return match(line, '\v^\s*%()?\s*\zs') 707 | endif 708 | let i -= 1 709 | endwhile 710 | return 0 711 | endif 712 | return match(line, '\v\s*\zs') 713 | endif 714 | if getline(s:prevnonblank(v:lnum - 1)) =~# '\v^\s*\s*%(--.*)?$' 715 | return indent(s:prevnonblank(v:lnum - 1)) + &shiftwidth 716 | endif 717 | return indent(s:prevnonblank(v:lnum - 1)) 718 | endfunction 719 | 720 | let &cpo = s:save_cpo 721 | unlet s:save_cpo 722 | -------------------------------------------------------------------------------- /test/case/case.in.hs: -------------------------------------------------------------------------------- 1 | f x = case x of 2 | 1 -> 0 3 | 2 -> 1 4 | _ -> x 5 | -------------------------------------------------------------------------------- /test/case/case.out.hs: -------------------------------------------------------------------------------- 1 | f x = case x of 2 | 1 -> 0 3 | 2 -> 1 4 | _ -> x 5 | -------------------------------------------------------------------------------- /test/case/case_guard.in.hs: -------------------------------------------------------------------------------- 1 | f x | x < 10 = case x of 2 | 1 -> 1 3 | 2 -> 0 4 | _ -> x 5 | | otherwise = case x of 6 | 10 -> 1 7 | 20 -> 0 8 | _ -> x 9 | -------------------------------------------------------------------------------- /test/case/case_guard.out.hs: -------------------------------------------------------------------------------- 1 | f x | x < 10 = case x of 2 | 1 -> 1 3 | 2 -> 0 4 | _ -> x 5 | | otherwise = case x of 6 | 10 -> 1 7 | 20 -> 0 8 | _ -> x 9 | -------------------------------------------------------------------------------- /test/case/case_let_in.in.hs: -------------------------------------------------------------------------------- 1 | h = f 2 | where 3 | f x = case x of 4 | 1 -> let y = g x 5 | in y 6 | 4 -> let y = g x 7 | in y 8 | _ -> let y = g x 9 | in y 10 | -------------------------------------------------------------------------------- /test/case/case_let_in.out.hs: -------------------------------------------------------------------------------- 1 | h = f 2 | where 3 | f x = case x of 4 | 1 -> let y = g x 5 | in y 6 | 4 -> let y = g x 7 | in y 8 | _ -> let y = g x 9 | in y 10 | -------------------------------------------------------------------------------- /test/case/case_same_line.in.hs: -------------------------------------------------------------------------------- 1 | f x = case x of 1 -> 0 2 | 2 -> 1 3 | _ -> (-x) 4 | g x = x 5 | -------------------------------------------------------------------------------- /test/case/case_same_line.out.hs: -------------------------------------------------------------------------------- 1 | f x = case x of 1 -> 0 2 | 2 -> 1 3 | _ -> (-x) 4 | g x = x 5 | -------------------------------------------------------------------------------- /test/case/case_same_line_parenthesis.in.hs: -------------------------------------------------------------------------------- 1 | f x = F (case x of -1 -> 0 2 | 2 -> 1 3 | _ -> (-x)) 4 | g x = x 5 | -------------------------------------------------------------------------------- /test/case/case_same_line_parenthesis.out.hs: -------------------------------------------------------------------------------- 1 | f x = F (case x of -1 -> 0 2 | 2 -> 1 3 | _ -> (-x)) 4 | g x = x 5 | -------------------------------------------------------------------------------- /test/case/caseif.in.hs: -------------------------------------------------------------------------------- 1 | h x = x 2 | where 3 | f x = case x of 4 | 1 -> if g x 5 | then 2 6 | else 3 7 | 4 -> if g x 8 | then 5 9 | else 6 10 | _ -> if g x 11 | then 7 12 | else 8 13 | g x = False 14 | -------------------------------------------------------------------------------- /test/case/caseif.out.hs: -------------------------------------------------------------------------------- 1 | h x = x 2 | where 3 | f x = case x of 4 | 1 -> if g x 5 | then 2 6 | else 3 7 | 4 -> if g x 8 | then 5 9 | else 6 10 | _ -> if g x 11 | then 7 12 | else 8 13 | g x = False 14 | -------------------------------------------------------------------------------- /test/case/disable_case.in.hs: -------------------------------------------------------------------------------- 1 | :let g:haskell_indent_disable_case = 1 2 | af x = case x of 3 | 1 -> 0 4 | 2 -> 1 5 | _ -> x 6 | -------------------------------------------------------------------------------- /test/case/disable_case.out.hs: -------------------------------------------------------------------------------- 1 | f x = case x of 2 | 1 -> 0 3 | 2 -> 1 4 | _ -> x 5 | -------------------------------------------------------------------------------- /test/case/disable_case_case_let_in.in.hs: -------------------------------------------------------------------------------- 1 | :let g:haskell_indent_disable_case = 1 2 | ah = f 3 | where 4 | f x = case x of 5 | 1 -> let y = g x 6 | in y 7 | 4 -> let y = g x 8 | in y 9 | _ -> let y = g x 10 | in y 11 | -------------------------------------------------------------------------------- /test/case/disable_case_case_let_in.out.hs: -------------------------------------------------------------------------------- 1 | h = f 2 | where 3 | f x = case x of 4 | 1 -> let y = g x 5 | in y 6 | 4 -> let y = g x 7 | in y 8 | _ -> let y = g x 9 | in y 10 | -------------------------------------------------------------------------------- /test/case/disable_case_caseif.in.hs: -------------------------------------------------------------------------------- 1 | :let g:haskell_indent_disable_case = 1 2 | ah x = x 3 | where 4 | f x = case x of 5 | 1 -> if g x 6 | then 2 7 | else 3 8 | 4 -> if g x 9 | then 5 10 | else 6 11 | _ -> if g x 12 | then 7 13 | else 8 14 | g x = False 15 | -------------------------------------------------------------------------------- /test/case/disable_case_caseif.out.hs: -------------------------------------------------------------------------------- 1 | h x = x 2 | where 3 | f x = case x of 4 | 1 -> if g x 5 | then 2 6 | else 3 7 | 4 -> if g x 8 | then 5 9 | else 6 10 | _ -> if g x 11 | then 7 12 | else 8 13 | g x = False 14 | -------------------------------------------------------------------------------- /test/case/disable_case_where_case.in.hs: -------------------------------------------------------------------------------- 1 | :let g:haskell_indent_disable_case = 1 2 | af = g 3 | where g x = case x of 4 | 1 -> 1 5 | 2 -> 0 6 | _ -> x 7 | h x = x 8 | -------------------------------------------------------------------------------- /test/case/disable_case_where_case.out.hs: -------------------------------------------------------------------------------- 1 | f = g 2 | where g x = case x of 3 | 1 -> 1 4 | 2 -> 0 5 | _ -> x 6 | h x = x 7 | -------------------------------------------------------------------------------- /test/case/lambda_case.in.hs: -------------------------------------------------------------------------------- 1 | f = \case 2 | 1 -> 0 3 | 2 -> 1 4 | x -> g x 5 | where g = \case 6 | x -> x 7 | -------------------------------------------------------------------------------- /test/case/lambda_case.out.hs: -------------------------------------------------------------------------------- 1 | f = \case 2 | 1 -> 0 3 | 2 -> 1 4 | x -> g x 5 | where g = \case 6 | x -> x 7 | -------------------------------------------------------------------------------- /test/case/lambda_case_literal.in.hs: -------------------------------------------------------------------------------- 1 | f = \case [] -> 0 2 | "one" -> 1 3 | '0':_ -> 0 4 | xs@('-':_) -> g $ read xs 5 | where g = \case -1 -> -100 6 | _ -> -1 7 | -------------------------------------------------------------------------------- /test/case/lambda_case_literal.out.hs: -------------------------------------------------------------------------------- 1 | f = \case [] -> 0 2 | "one" -> 1 3 | '0':_ -> 0 4 | xs@('-':_) -> g $ read xs 5 | where g = \case -1 -> -100 6 | _ -> -1 7 | -------------------------------------------------------------------------------- /test/case/lambda_case_same_line.in.hs: -------------------------------------------------------------------------------- 1 | f = \case 1 -> 0 2 | 2 -> 1 3 | x -> g x 4 | where g = \ case -1 -> -1 5 | _ -> 3 6 | -------------------------------------------------------------------------------- /test/case/lambda_case_same_line.out.hs: -------------------------------------------------------------------------------- 1 | f = \case 1 -> 0 2 | 2 -> 1 3 | x -> g x 4 | where g = \ case -1 -> -1 5 | _ -> 3 6 | -------------------------------------------------------------------------------- /test/case/where_case.in.hs: -------------------------------------------------------------------------------- 1 | f = g 2 | where g x = case x of 3 | 1 -> 1 4 | 2 -> 0 5 | _ -> x 6 | h x = x 7 | -------------------------------------------------------------------------------- /test/case/where_case.out.hs: -------------------------------------------------------------------------------- 1 | f = g 2 | where g x = case x of 3 | 1 -> 1 4 | 2 -> 0 5 | _ -> x 6 | h x = x 7 | -------------------------------------------------------------------------------- /test/class/class.in.hs: -------------------------------------------------------------------------------- 1 | class X where 2 | foo :: Int 3 | -------------------------------------------------------------------------------- /test/class/class.out.hs: -------------------------------------------------------------------------------- 1 | class X where 2 | foo :: Int 3 | -------------------------------------------------------------------------------- /test/class/class_where.in.hs: -------------------------------------------------------------------------------- 1 | class X where 2 | f = g 3 | where 4 | g = h 5 | -------------------------------------------------------------------------------- /test/class/class_where.out.hs: -------------------------------------------------------------------------------- 1 | class X where 2 | f = g 3 | where 4 | g = h 5 | -------------------------------------------------------------------------------- /test/comment/after_module_where.in.hs: -------------------------------------------------------------------------------- 1 | module Foo where 2 | -- Foo 3 | foo = 10 4 | -------------------------------------------------------------------------------- /test/comment/after_module_where.out.hs: -------------------------------------------------------------------------------- 1 | module Foo where 2 | -- Foo 3 | foo = 10 4 | -------------------------------------------------------------------------------- /test/comment/after_where.in.hs: -------------------------------------------------------------------------------- 1 | f x = q 2 | where 3 | -- q 4 | q = 10 5 | -------------------------------------------------------------------------------- /test/comment/after_where.out.hs: -------------------------------------------------------------------------------- 1 | f x = q 2 | where 3 | -- q 4 | q = 10 5 | -------------------------------------------------------------------------------- /test/comment/before_blank_line_and_class.in.hs: -------------------------------------------------------------------------------- 1 | class X where 2 | foo :: Int 3 | a 4 | 5 | -- | Y 6 | -- Y is something 7 | -- nice. 8 | 9 | class Y where 10 | bar :: Int 11 | -------------------------------------------------------------------------------- /test/comment/before_blank_line_and_class.out.hs: -------------------------------------------------------------------------------- 1 | class X where 2 | foo :: Int 3 | 4 | 5 | -- | Y 6 | -- Y is something 7 | -- nice. 8 | 9 | class Y where 10 | bar :: Int 11 | -------------------------------------------------------------------------------- /test/comment/before_class.in.hs: -------------------------------------------------------------------------------- 1 | class X where 2 | foo :: Int 3 | a-- | Y 4 | -- Y is something 5 | -- nice. 6 | class Y where 7 | bar :: Int 8 | -------------------------------------------------------------------------------- /test/comment/before_class.out.hs: -------------------------------------------------------------------------------- 1 | class X where 2 | foo :: Int 3 | -- | Y 4 | -- Y is something 5 | -- nice. 6 | class Y where 7 | bar :: Int 8 | -------------------------------------------------------------------------------- /test/comment/before_data.in.hs: -------------------------------------------------------------------------------- 1 | data X = A 2 | | B 3 | a-- | Y 4 | -- Y is something 5 | -- nice. 6 | data Y = C 7 | | D 8 | -------------------------------------------------------------------------------- /test/comment/before_data.out.hs: -------------------------------------------------------------------------------- 1 | data X = A 2 | | B 3 | -- | Y 4 | -- Y is something 5 | -- nice. 6 | data Y = C 7 | | D 8 | -------------------------------------------------------------------------------- /test/comment/before_instance.in.hs: -------------------------------------------------------------------------------- 1 | instance X A where 2 | foo :: Int 3 | a-- | B 4 | -- B is something 5 | -- nice. 6 | instance Y B where 7 | bar :: Int 8 | -------------------------------------------------------------------------------- /test/comment/before_instance.out.hs: -------------------------------------------------------------------------------- 1 | instance X A where 2 | foo :: Int 3 | -- | B 4 | -- B is something 5 | -- nice. 6 | instance Y B where 7 | bar :: Int 8 | -------------------------------------------------------------------------------- /test/comment/block_comment.in.hs: -------------------------------------------------------------------------------- 1 | {- 2 | foo 3 | bar 4 | baz 5 | import X ( 6 | module 7 | instance X Y where 8 | if x 9 | then y 10 | else z 11 | -} 12 | -------------------------------------------------------------------------------- /test/comment/block_comment.out.hs: -------------------------------------------------------------------------------- 1 | {- 2 | foo 3 | bar 4 | baz 5 | import X ( 6 | module 7 | instance X Y where 8 | if x 9 | then y 10 | else z 11 | -} 12 | -------------------------------------------------------------------------------- /test/comment/block_comment_where.in.hs: -------------------------------------------------------------------------------- 1 | {--- 2 | foo 3 | bar 4 | baz 5 | ---} 6 | f x = g x 7 | where g = id 8 | -------------------------------------------------------------------------------- /test/comment/block_comment_where.out.hs: -------------------------------------------------------------------------------- 1 | {--- 2 | foo 3 | bar 4 | baz 5 | ---} 6 | f x = g x 7 | where g = id 8 | -------------------------------------------------------------------------------- /test/comment/class_comments.in.hs: -------------------------------------------------------------------------------- 1 | class X where 2 | -- foo 3 | foo :: Int 4 | foo = 10 5 | -------------------------------------------------------------------------------- /test/comment/class_comments.out.hs: -------------------------------------------------------------------------------- 1 | class X where 2 | -- foo 3 | foo :: Int 4 | foo = 10 5 | -------------------------------------------------------------------------------- /test/comment/double_block_comments.in.hs: -------------------------------------------------------------------------------- 1 | {- 2 | foo 3 | bar 4 | -} 5 | {- 6 | module 7 | class X where 8 | yyy 9 | -} 10 | -------------------------------------------------------------------------------- /test/comment/double_block_comments.out.hs: -------------------------------------------------------------------------------- 1 | {- 2 | foo 3 | bar 4 | -} 5 | {- 6 | module 7 | class X where 8 | yyy 9 | -} 10 | -------------------------------------------------------------------------------- /test/comment/line_comments.in.hs: -------------------------------------------------------------------------------- 1 | -- foo 2 | -- bar 3 | -- baz where 4 | foo = 10 5 | -------------------------------------------------------------------------------- /test/comment/line_comments.out.hs: -------------------------------------------------------------------------------- 1 | -- foo 2 | -- bar 3 | -- baz where 4 | foo = 10 5 | -------------------------------------------------------------------------------- /test/comment/list.in.hs: -------------------------------------------------------------------------------- 1 | {- 2 | foo 3 | bar 4 | 5 | a) foo 6 | foo 7 | a b) bar 8 | bar 9 | 10 | baa 11 | -} 12 | {- 13 | foo 14 | bar 15 | * @foo 16 | * @bar 17 | abaa 18 | -} 19 | {- 20 | foo 21 | bar 22 | > foo 23 | > bar 24 | abaa 25 | -} 26 | -------------------------------------------------------------------------------- /test/comment/list.out.hs: -------------------------------------------------------------------------------- 1 | {- 2 | foo 3 | bar 4 | 5 | a) foo 6 | foo 7 | b) bar 8 | bar 9 | 10 | baa 11 | -} 12 | {- 13 | foo 14 | bar 15 | * @foo 16 | * @bar 17 | baa 18 | -} 19 | {- 20 | foo 21 | bar 22 | > foo 23 | > bar 24 | baa 25 | -} 26 | -------------------------------------------------------------------------------- /test/comment/module_comments.in.hs: -------------------------------------------------------------------------------- 1 | module X 2 | ( 3 | -- foo 4 | foo, 5 | -- bar 6 | bar 7 | ) where 8 | 9 | -------------------------------------------------------------------------------- /test/comment/module_comments.out.hs: -------------------------------------------------------------------------------- 1 | module X 2 | ( 3 | -- foo 4 | foo, 5 | -- bar 6 | bar 7 | ) where 8 | 9 | -------------------------------------------------------------------------------- /test/comment/module_lines_comments.in.hs: -------------------------------------------------------------------------------- 1 | module X 2 | ( 3 | -- foo 4 | foo, 5 | 6 | -- bar 7 | bar, 8 | 9 | -- baz 10 | baz 11 | ) where 12 | -------------------------------------------------------------------------------- /test/comment/module_lines_comments.out.hs: -------------------------------------------------------------------------------- 1 | module X 2 | ( 3 | -- foo 4 | foo, 5 | 6 | -- bar 7 | bar, 8 | 9 | -- baz 10 | baz 11 | ) where 12 | -------------------------------------------------------------------------------- /test/comment/splitter.in.hs: -------------------------------------------------------------------------------- 1 | class X where 2 | foo :: Int 3 | 4 | a-- ----------- 5 | -- The Y class 6 | class Y where 7 | bar :: Int 8 | -------------------------------------------------------------------------------- /test/comment/splitter.out.hs: -------------------------------------------------------------------------------- 1 | class X where 2 | foo :: Int 3 | 4 | -- ----------- 5 | -- The Y class 6 | class Y where 7 | bar :: Int 8 | -------------------------------------------------------------------------------- /test/comment/top_level_block_comment.in.hs: -------------------------------------------------------------------------------- 1 | class X where 2 | x :: Int 3 | a{- | 4 | Another Class 5 | -} 6 | -------------------------------------------------------------------------------- /test/comment/top_level_block_comment.out.hs: -------------------------------------------------------------------------------- 1 | class X where 2 | x :: Int 3 | {- | 4 | Another Class 5 | -} 6 | -------------------------------------------------------------------------------- /test/datatype/after_deriving.in.hs: -------------------------------------------------------------------------------- 1 | data X a = L a 2 | | N 3 | deriving Eq 4 | f x = x 5 | -------------------------------------------------------------------------------- /test/datatype/after_deriving.out.hs: -------------------------------------------------------------------------------- 1 | data X a = L a 2 | | N 3 | deriving Eq 4 | f x = x 5 | -------------------------------------------------------------------------------- /test/datatype/after_deriving_lines.in.hs: -------------------------------------------------------------------------------- 1 | data X a = L a 2 | | N 3 | deriving ( Eq, 4 | Ord, 5 | Show ) 6 | f x = x 7 | -------------------------------------------------------------------------------- /test/datatype/after_deriving_lines.out.hs: -------------------------------------------------------------------------------- 1 | data X a = L a 2 | | N 3 | deriving ( Eq, 4 | Ord, 5 | Show ) 6 | f x = x 7 | -------------------------------------------------------------------------------- /test/datatype/after_deriving_lines_comma_first.in.hs: -------------------------------------------------------------------------------- 1 | data X a = L a 2 | | N 3 | deriving ( Eq 4 | , Ord 5 | , Show ) 6 | f x = x 7 | -------------------------------------------------------------------------------- /test/datatype/after_deriving_lines_comma_first.out.hs: -------------------------------------------------------------------------------- 1 | data X a = L a 2 | | N 3 | deriving ( Eq 4 | , Ord 5 | , Show ) 6 | f x = x 7 | -------------------------------------------------------------------------------- /test/datatype/after_deriving_parenthesis.in.hs: -------------------------------------------------------------------------------- 1 | data X a = L a 2 | | N 3 | deriving (Eq, Show, Ord) 4 | f x = x 5 | -------------------------------------------------------------------------------- /test/datatype/after_deriving_parenthesis.out.hs: -------------------------------------------------------------------------------- 1 | data X a = L a 2 | | N 3 | deriving (Eq, Show, Ord) 4 | f x = x 5 | -------------------------------------------------------------------------------- /test/datatype/datatype.in.hs: -------------------------------------------------------------------------------- 1 | data X a = L a 2 | | N 3 | deriving Eq 4 | -------------------------------------------------------------------------------- /test/datatype/datatype.out.hs: -------------------------------------------------------------------------------- 1 | data X a = L a 2 | | N 3 | deriving Eq 4 | -------------------------------------------------------------------------------- /test/datatype/datatype_eq.in.hs: -------------------------------------------------------------------------------- 1 | data X 2 | = X 3 | | Y 4 | | Z 5 | -------------------------------------------------------------------------------- /test/datatype/datatype_eq.out.hs: -------------------------------------------------------------------------------- 1 | data X 2 | = X 3 | | Y 4 | | Z 5 | -------------------------------------------------------------------------------- /test/datatype/enter_enter.in.hs: -------------------------------------------------------------------------------- 1 | data X a = L a 2 | | N 3 | 4 | f x = x 5 | -------------------------------------------------------------------------------- /test/datatype/enter_enter.out.hs: -------------------------------------------------------------------------------- 1 | data X a = L a 2 | | N 3 | 4 | f x = x 5 | -------------------------------------------------------------------------------- /test/datatype/gadt.in.hs: -------------------------------------------------------------------------------- 1 | data X a where 2 | I :: Int -> X Int 3 | -------------------------------------------------------------------------------- /test/datatype/gadt.out.hs: -------------------------------------------------------------------------------- 1 | data X a where 2 | I :: Int -> X Int 3 | -------------------------------------------------------------------------------- /test/datatype/multiple.in.hs: -------------------------------------------------------------------------------- 1 | data X = A | B 2 | data Y = C | D 3 | data Z = E | F 4 | -------------------------------------------------------------------------------- /test/datatype/multiple.out.hs: -------------------------------------------------------------------------------- 1 | data X = A | B 2 | data Y = C | D 3 | data Z = E | F 4 | -------------------------------------------------------------------------------- /test/datatype/multiple_type.in.hs: -------------------------------------------------------------------------------- 1 | data X = A | B 2 | data Y = C | D 3 | type W = X 4 | data Z = E | F 5 | -------------------------------------------------------------------------------- /test/datatype/multiple_type.out.hs: -------------------------------------------------------------------------------- 1 | data X = A | B 2 | data Y = C | D 3 | type W = X 4 | data Z = E | F 5 | -------------------------------------------------------------------------------- /test/datatype/no_newline.in.hs: -------------------------------------------------------------------------------- 1 | data X = A | B | C 2 | deriving Eq 3 | -------------------------------------------------------------------------------- /test/datatype/no_newline.out.hs: -------------------------------------------------------------------------------- 1 | data X = A | B | C 2 | deriving Eq 3 | -------------------------------------------------------------------------------- /test/datatype/reindent.in.hs: -------------------------------------------------------------------------------- 1 | data X a = L a 2 | a| N 3 | aderiving Eq 4 | -------------------------------------------------------------------------------- /test/datatype/reindent.out.hs: -------------------------------------------------------------------------------- 1 | data X a = L a 2 | | N 3 | deriving Eq 4 | -------------------------------------------------------------------------------- /test/datatype/type_family.in.hs: -------------------------------------------------------------------------------- 1 | class X k => G k where 2 | data GM k :: * -> * 3 | a :: GM k v 4 | 5 | instance X Int where 6 | data GM Int v = GMI (Map.Map Int v) 7 | a = GMI Map.empty 8 | 9 | instance X Char where 10 | data GM Char v = GMI (Map.Map Char v) 11 | a = GMI Map.empty 12 | 13 | class Y y where 14 | type E e 15 | z :: e 16 | 17 | instance Y Int where 18 | type E = Int 19 | z = 0 20 | 21 | type family G a where 22 | G Int = Bool 23 | G a = Char 24 | -------------------------------------------------------------------------------- /test/datatype/type_family.out.hs: -------------------------------------------------------------------------------- 1 | class X k => G k where 2 | data GM k :: * -> * 3 | a :: GM k v 4 | 5 | instance X Int where 6 | data GM Int v = GMI (Map.Map Int v) 7 | a = GMI Map.empty 8 | 9 | instance X Char where 10 | data GM Char v = GMI (Map.Map Char v) 11 | a = GMI Map.empty 12 | 13 | class Y y where 14 | type E e 15 | z :: e 16 | 17 | instance Y Int where 18 | type E = Int 19 | z = 0 20 | 21 | type family G a where 22 | G Int = Bool 23 | G a = Char 24 | -------------------------------------------------------------------------------- /test/do/do_enter_enter.in.hs: -------------------------------------------------------------------------------- 1 | main = do 2 | 3 | 4 | print "hello" 5 | -------------------------------------------------------------------------------- /test/do/do_enter_enter.out.hs: -------------------------------------------------------------------------------- 1 | main = do 2 | 3 | 4 | print "hello" 5 | -------------------------------------------------------------------------------- /test/do/do_same_line.in.hs: -------------------------------------------------------------------------------- 1 | main = do print "hello" 2 | print "world" 3 | -------------------------------------------------------------------------------- /test/do/do_same_line.out.hs: -------------------------------------------------------------------------------- 1 | main = do print "hello" 2 | print "world" 3 | -------------------------------------------------------------------------------- /test/do/double_do.in.hs: -------------------------------------------------------------------------------- 1 | do foo <- do undo <- baz 2 | qux 3 | quux 4 | -------------------------------------------------------------------------------- /test/do/double_do.out.hs: -------------------------------------------------------------------------------- 1 | do foo <- do undo <- baz 2 | qux 3 | quux 4 | -------------------------------------------------------------------------------- /test/do/let_do.in.hs: -------------------------------------------------------------------------------- 1 | z = let f x = do 2 | print "hello" 3 | in f 0 4 | -------------------------------------------------------------------------------- /test/do/let_do.out.hs: -------------------------------------------------------------------------------- 1 | z = let f x = do 2 | print "hello" 3 | in f 0 4 | -------------------------------------------------------------------------------- /test/do/main_do.in.hs: -------------------------------------------------------------------------------- 1 | main = do 2 | print "hello" 3 | -------------------------------------------------------------------------------- /test/do/main_do.out.hs: -------------------------------------------------------------------------------- 1 | main = do 2 | print "hello" 3 | -------------------------------------------------------------------------------- /test/do/main_do_sw4.in.hs: -------------------------------------------------------------------------------- 1 | :set shiftwidth=4amain = do 2 | print "hello" 3 | -------------------------------------------------------------------------------- /test/do/main_do_sw4.out.hs: -------------------------------------------------------------------------------- 1 | main = do 2 | print "hello" 3 | -------------------------------------------------------------------------------- /test/do/main_do_sw8.in.hs: -------------------------------------------------------------------------------- 1 | :set shiftwidth=8amain = do 2 | print "hello" 3 | -------------------------------------------------------------------------------- /test/do/main_do_sw8.out.hs: -------------------------------------------------------------------------------- 1 | main = do 2 | print "hello" 3 | -------------------------------------------------------------------------------- /test/do/where_do.in.hs: -------------------------------------------------------------------------------- 1 | z = x 2 | where f x = do 3 | print "hello" 4 | -------------------------------------------------------------------------------- /test/do/where_do.out.hs: -------------------------------------------------------------------------------- 1 | z = x 2 | where f x = do 3 | print "hello" 4 | -------------------------------------------------------------------------------- /test/function/function.in.hs: -------------------------------------------------------------------------------- 1 | f :: Int -> Int 2 | f x = x 3 | -------------------------------------------------------------------------------- /test/function/function.out.hs: -------------------------------------------------------------------------------- 1 | f :: Int -> Int 2 | f x = x 3 | -------------------------------------------------------------------------------- /test/function/function_break_line.in.hs: -------------------------------------------------------------------------------- 1 | f = \x -> 2 | x 3 | -------------------------------------------------------------------------------- /test/function/function_break_line.out.hs: -------------------------------------------------------------------------------- 1 | f = \x -> 2 | x 3 | -------------------------------------------------------------------------------- /test/function/function_break_lines.in.hs: -------------------------------------------------------------------------------- 1 | g = f 2 | where 3 | f = \x -> 4 | \y -> 5 | (x, y) 6 | -------------------------------------------------------------------------------- /test/function/function_break_lines.out.hs: -------------------------------------------------------------------------------- 1 | g = f 2 | where 3 | f = \x -> 4 | \y -> 5 | (x, y) 6 | -------------------------------------------------------------------------------- /test/function/function_eq_first.in.hs: -------------------------------------------------------------------------------- 1 | f :: Int -> Int 2 | f 0 3 | = 1 4 | f x 5 | = x 6 | -------------------------------------------------------------------------------- /test/function/function_eq_first.out.hs: -------------------------------------------------------------------------------- 1 | f :: Int -> Int 2 | f 0 3 | = 1 4 | f x 5 | = x 6 | -------------------------------------------------------------------------------- /test/function/function_eq_last.in.hs: -------------------------------------------------------------------------------- 1 | f :: Int -> Int 2 | f x = 3 | x 4 | -------------------------------------------------------------------------------- /test/function/function_eq_last.out.hs: -------------------------------------------------------------------------------- 1 | f :: Int -> Int 2 | f x = 3 | x 4 | -------------------------------------------------------------------------------- /test/function/function_eq_last_after.in.hs: -------------------------------------------------------------------------------- 1 | q = 0 2 | where 3 | f x = 4 | x 5 | g x = x 6 | h x = 7 | (x) 8 | i = 0 9 | j x = 10 | [ x | x <- [0..10] ] 11 | k = 0 12 | -------------------------------------------------------------------------------- /test/function/function_eq_last_after.out.hs: -------------------------------------------------------------------------------- 1 | q = 0 2 | where 3 | f x = 4 | x 5 | g x = x 6 | h x = 7 | (x) 8 | i = 0 9 | j x = 10 | [ x | x <- [0..10] ] 11 | k = 0 12 | -------------------------------------------------------------------------------- /test/function/where_function_eq_first.in.hs: -------------------------------------------------------------------------------- 1 | g = f 2 | where 3 | f :: Int -> Int 4 | f 0 5 | = 1 6 | f x 7 | = x 8 | -------------------------------------------------------------------------------- /test/function/where_function_eq_first.out.hs: -------------------------------------------------------------------------------- 1 | g = f 2 | where 3 | f :: Int -> Int 4 | f 0 5 | = 1 6 | f x 7 | = x 8 | -------------------------------------------------------------------------------- /test/guard/case_guard.in.hs: -------------------------------------------------------------------------------- 1 | f x = case x of 2 | 1 -> 0 3 | y | y < 10 -> 10 - y 4 | | otherwise -> y 5 | -------------------------------------------------------------------------------- /test/guard/case_guard.out.hs: -------------------------------------------------------------------------------- 1 | f x = case x of 2 | 1 -> 0 3 | y | y < 10 -> 10 - y 4 | | otherwise -> y 5 | -------------------------------------------------------------------------------- /test/guard/guard.in.hs: -------------------------------------------------------------------------------- 1 | f x | x > 10 = 10 2 | | x < 0 = 0 3 | | otherwise = x 4 | g x = 10 5 | -------------------------------------------------------------------------------- /test/guard/guard.out.hs: -------------------------------------------------------------------------------- 1 | f x | x > 10 = 10 2 | | x < 0 = 0 3 | | otherwise = x 4 | g x = 10 5 | -------------------------------------------------------------------------------- /test/guard/instance_guard.in.hs: -------------------------------------------------------------------------------- 1 | instance X Y where 2 | f (X x) (Y y) 3 | | g x = x 4 | | otherwise = y 5 | g = h 6 | -------------------------------------------------------------------------------- /test/guard/instance_guard.out.hs: -------------------------------------------------------------------------------- 1 | instance X Y where 2 | f (X x) (Y y) 3 | | g x = x 4 | | otherwise = y 5 | g = h 6 | -------------------------------------------------------------------------------- /test/guard/noindent.in.hs: -------------------------------------------------------------------------------- 1 | f x | x > 10 = x 2 | af 0 = -100 3 | f x | otherwise = x 4 | -------------------------------------------------------------------------------- /test/guard/noindent.out.hs: -------------------------------------------------------------------------------- 1 | f x | x > 10 = x 2 | f 0 = -100 3 | f x | otherwise = x 4 | -------------------------------------------------------------------------------- /test/guard/or.in.hs: -------------------------------------------------------------------------------- 1 | f xs ys 2 | | null xs || null ys = [] 3 | | otherwise = [] 4 | -------------------------------------------------------------------------------- /test/guard/or.out.hs: -------------------------------------------------------------------------------- 1 | f xs ys 2 | | null xs || null ys = [] 3 | | otherwise = [] 4 | -------------------------------------------------------------------------------- /test/guard/reindent.in.hs: -------------------------------------------------------------------------------- 1 | f x | x > 10 = 10 2 | a| x < 0 = 0 3 | a| otherwise = x 4 | -------------------------------------------------------------------------------- /test/guard/reindent.out.hs: -------------------------------------------------------------------------------- 1 | f x | x > 10 = 10 2 | | x < 0 = 0 3 | | otherwise = x 4 | -------------------------------------------------------------------------------- /test/guard/top_of_line.in.hs: -------------------------------------------------------------------------------- 1 | f y@(x:xs) 2 | | x > 10 = let z = [] in (z) 3 | | otherwise = [] 4 | -------------------------------------------------------------------------------- /test/guard/top_of_line.out.hs: -------------------------------------------------------------------------------- 1 | f y@(x:xs) 2 | | x > 10 = let z = [] in (z) 3 | | otherwise = [] 4 | -------------------------------------------------------------------------------- /test/guard/where_case_guard.in.hs: -------------------------------------------------------------------------------- 1 | f = g 2 | where 3 | g x = case x of 4 | 1 -> 0 5 | y | y < 10 -> 10 - y 6 | | otherwise -> y 7 | -------------------------------------------------------------------------------- /test/guard/where_case_guard.out.hs: -------------------------------------------------------------------------------- 1 | f = g 2 | where 3 | g x = case x of 4 | 1 -> 0 5 | y | y < 10 -> 10 - y 6 | | otherwise -> y 7 | -------------------------------------------------------------------------------- /test/guard/where_same_line.in.hs: -------------------------------------------------------------------------------- 1 | g = f 2 | where 3 | f y@(x:xs) | x > 10 = let z = [] in (z) 4 | | otherwise = [] 5 | -------------------------------------------------------------------------------- /test/guard/where_same_line.out.hs: -------------------------------------------------------------------------------- 1 | g = f 2 | where 3 | f y@(x:xs) | x > 10 = let z = [] in (z) 4 | | otherwise = [] 5 | -------------------------------------------------------------------------------- /test/guard/where_sameline_guard.in.hs: -------------------------------------------------------------------------------- 1 | g = f 2 | where f y@(x:xs) 3 | | x > 10 = let z = [] in (z) 4 | | otherwise = [] 5 | -------------------------------------------------------------------------------- /test/guard/where_sameline_guard.out.hs: -------------------------------------------------------------------------------- 1 | g = f 2 | where f y@(x:xs) 3 | | x > 10 = let z = [] in (z) 4 | | otherwise = [] 5 | -------------------------------------------------------------------------------- /test/guard/where_top_of_line.in.hs: -------------------------------------------------------------------------------- 1 | g = f 2 | where 3 | f y@(x:xs) 4 | | x > 10 = let z = [] in (z) 5 | | otherwise = [] 6 | -------------------------------------------------------------------------------- /test/guard/where_top_of_line.out.hs: -------------------------------------------------------------------------------- 1 | g = f 2 | where 3 | f y@(x:xs) 4 | | x > 10 = let z = [] in (z) 5 | | otherwise = [] 6 | -------------------------------------------------------------------------------- /test/if/guard.in.hs: -------------------------------------------------------------------------------- 1 | f x | x > 1 = if x > 2 2 | then 2 3 | else 1 4 | | otherwise = 0 5 | -------------------------------------------------------------------------------- /test/if/guard.out.hs: -------------------------------------------------------------------------------- 1 | f x | x > 1 = if x > 2 2 | then 2 3 | else 1 4 | | otherwise = 0 5 | -------------------------------------------------------------------------------- /test/if/ifthen.in.hs: -------------------------------------------------------------------------------- 1 | f x = if x > 2 2 | then 2 3 | else 1 4 | -------------------------------------------------------------------------------- /test/if/ifthen.out.hs: -------------------------------------------------------------------------------- 1 | f x = if x > 2 2 | then 2 3 | else 1 4 | -------------------------------------------------------------------------------- /test/if/ifthen_sameline.in.hs: -------------------------------------------------------------------------------- 1 | f x = if x > 2 then 2 else 1 2 | g x = x 3 | -------------------------------------------------------------------------------- /test/if/ifthen_sameline.out.hs: -------------------------------------------------------------------------------- 1 | f x = if x > 2 then 2 else 1 2 | g x = x 3 | -------------------------------------------------------------------------------- /test/if/ifthendo.in.hs: -------------------------------------------------------------------------------- 1 | f x = if x > 2 2 | then do 3 | print "x" 4 | else do 5 | print "y" 6 | -------------------------------------------------------------------------------- /test/if/ifthendo.out.hs: -------------------------------------------------------------------------------- 1 | f x = if x > 2 2 | then do 3 | print "x" 4 | else do 5 | print "y" 6 | -------------------------------------------------------------------------------- /test/if/ifthenelse_nested.in.hs: -------------------------------------------------------------------------------- 1 | if foo 2 | then if bar 3 | then baz 4 | else qux 5 | else quux 6 | -------------------------------------------------------------------------------- /test/if/ifthenelse_nested.out.hs: -------------------------------------------------------------------------------- 1 | if foo 2 | then if bar 3 | then baz 4 | else qux 5 | else quux 6 | -------------------------------------------------------------------------------- /test/infix/infix.in.hs: -------------------------------------------------------------------------------- 1 | infixr 9 . 2 | infixr 5 ++ 3 | infixl 4 <$ 4 | infix 2 `foo` 5 | infixl 1 >>, >>= 6 | infixr 1 =<< 7 | 8 | infixr 0 $, $! 9 | 10 | 11 | infixl 4 <*>, <*, *>, <**> 12 | -------------------------------------------------------------------------------- /test/infix/infix.out.hs: -------------------------------------------------------------------------------- 1 | infixr 9 . 2 | infixr 5 ++ 3 | infixl 4 <$ 4 | infix 2 `foo` 5 | infixl 1 >>, >>= 6 | infixr 1 =<< 7 | 8 | infixr 0 $, $! 9 | 10 | 11 | infixl 4 <*>, <*, *>, <**> 12 | -------------------------------------------------------------------------------- /test/instance/instance.in.hs: -------------------------------------------------------------------------------- 1 | instance X Y where 2 | f = g 3 | -------------------------------------------------------------------------------- /test/instance/instance.out.hs: -------------------------------------------------------------------------------- 1 | instance X Y where 2 | f = g 3 | -------------------------------------------------------------------------------- /test/instance/instance_elements.in.hs: -------------------------------------------------------------------------------- 1 | instance X Y where 2 | f = g 3 | h = i 4 | 5 | j = k 6 | -------------------------------------------------------------------------------- /test/instance/instance_elements.out.hs: -------------------------------------------------------------------------------- 1 | instance X Y where 2 | f = g 3 | h = i 4 | 5 | j = k 6 | -------------------------------------------------------------------------------- /test/instance/instance_newline.in.hs: -------------------------------------------------------------------------------- 1 | instance X => 2 | Y where 3 | f = g 4 | where 5 | g = h 6 | -------------------------------------------------------------------------------- /test/instance/instance_newline.out.hs: -------------------------------------------------------------------------------- 1 | instance X => 2 | Y where 3 | f = g 4 | where 5 | g = h 6 | -------------------------------------------------------------------------------- /test/instance/instance_newline_2.in.hs: -------------------------------------------------------------------------------- 1 | instance X Y 2 | where 3 | f = g 4 | where 5 | g = h 6 | -------------------------------------------------------------------------------- /test/instance/instance_newline_2.out.hs: -------------------------------------------------------------------------------- 1 | instance X Y 2 | where 3 | f = g 4 | where 5 | g = h 6 | -------------------------------------------------------------------------------- /test/instance/instance_no_where.in.hs: -------------------------------------------------------------------------------- 1 | instance X Y 2 | 3 | f = g 4 | -------------------------------------------------------------------------------- /test/instance/instance_no_where.out.hs: -------------------------------------------------------------------------------- 1 | instance X Y 2 | 3 | f = g 4 | -------------------------------------------------------------------------------- /test/instance/instance_where.in.hs: -------------------------------------------------------------------------------- 1 | instance X => Y where 2 | f = g 3 | where 4 | g = h 5 | -------------------------------------------------------------------------------- /test/instance/instance_where.out.hs: -------------------------------------------------------------------------------- 1 | instance X => Y where 2 | f = g 3 | where 4 | g = h 5 | -------------------------------------------------------------------------------- /test/instance/multiple_instance.in.hs: -------------------------------------------------------------------------------- 1 | instance X Y where 2 | f = g 3 | 4 | instance W U where 5 | f = g 6 | -------------------------------------------------------------------------------- /test/instance/multiple_instance.out.hs: -------------------------------------------------------------------------------- 1 | instance X Y where 2 | f = g 3 | 4 | instance W U where 5 | f = g 6 | -------------------------------------------------------------------------------- /test/instance/multiple_instance_no_where.in.hs: -------------------------------------------------------------------------------- 1 | instance X Y 2 | 3 | instance W U where 4 | f = g 5 | -------------------------------------------------------------------------------- /test/instance/multiple_instance_no_where.out.hs: -------------------------------------------------------------------------------- 1 | instance X Y 2 | 3 | instance W U where 4 | f = g 5 | -------------------------------------------------------------------------------- /test/let/let.in.hs: -------------------------------------------------------------------------------- 1 | f = let x = 0 2 | y = 1 3 | in (x, y) 4 | -------------------------------------------------------------------------------- /test/let/let.out.hs: -------------------------------------------------------------------------------- 1 | f = let x = 0 2 | y = 1 3 | in (x, y) 4 | -------------------------------------------------------------------------------- /test/let/let_in_let_in.in.hs: -------------------------------------------------------------------------------- 1 | f = let x = 0 2 | y = 1 3 | in let z = 2 4 | u = 3 5 | in (x, y, z, u) 6 | -------------------------------------------------------------------------------- /test/let/let_in_let_in.out.hs: -------------------------------------------------------------------------------- 1 | f = let x = 0 2 | y = 1 3 | in let z = 2 4 | u = 3 5 | in (x, y, z, u) 6 | -------------------------------------------------------------------------------- /test/let/let_in_same_line.in.hs: -------------------------------------------------------------------------------- 1 | f = let x = 0 in x 2 | where x = let y = 1 in y 3 | y = let z = 1 in z 4 | z = let w = 1 in w 5 | w = let x = 1 in x 6 | -------------------------------------------------------------------------------- /test/let/let_in_same_line.out.hs: -------------------------------------------------------------------------------- 1 | f = let x = 0 in x 2 | where x = let y = 1 in y 3 | y = let z = 1 in z 4 | z = let w = 1 in w 5 | w = let x = 1 in x 6 | -------------------------------------------------------------------------------- /test/let/let_let.in.hs: -------------------------------------------------------------------------------- 1 | f = do 2 | let x = 0 3 | let y = 0 4 | let z = 0 5 | return (x, y, z) 6 | -------------------------------------------------------------------------------- /test/let/let_let.out.hs: -------------------------------------------------------------------------------- 1 | f = do 2 | let x = 0 3 | let y = 0 4 | let z = 0 5 | return (x, y, z) 6 | -------------------------------------------------------------------------------- /test/let/let_monad.in.hs: -------------------------------------------------------------------------------- 1 | f = do 2 | let x = 0 3 | y <- return 0 4 | let z = 0 5 | w <- return 0 6 | return (x, y, z, w) 7 | -------------------------------------------------------------------------------- /test/let/let_monad.out.hs: -------------------------------------------------------------------------------- 1 | f = do 2 | let x = 0 3 | y <- return 0 4 | let z = 0 5 | w <- return 0 6 | return (x, y, z, w) 7 | -------------------------------------------------------------------------------- /test/list/arg_list.in.hs: -------------------------------------------------------------------------------- 1 | f [x, y, [z, w]] = [ 2 | x, y, 3 | [ 4 | z, 5 | w, 6 | ]] 7 | 8 | g [x, y] = x `div` 9 | y 10 | -------------------------------------------------------------------------------- /test/list/arg_list.out.hs: -------------------------------------------------------------------------------- 1 | f [x, y, [z, w]] = [ 2 | x, y, 3 | [ 4 | z, 5 | w, 6 | ]] 7 | 8 | g [x, y] = x `div` 9 | y 10 | -------------------------------------------------------------------------------- /test/list/arg_tuple.in.hs: -------------------------------------------------------------------------------- 1 | f (x, y, (z, w)) = [ 2 | x, ( 3 | y 4 | ), 5 | ( 6 | z, 7 | w 8 | )] 9 | 10 | g (x, y) = x + 11 | y 12 | -------------------------------------------------------------------------------- /test/list/arg_tuple.out.hs: -------------------------------------------------------------------------------- 1 | f (x, y, (z, w)) = [ 2 | x, ( 3 | y 4 | ), 5 | ( 6 | z, 7 | w 8 | )] 9 | 10 | g (x, y) = x + 11 | y 12 | -------------------------------------------------------------------------------- /test/list/comprehension_multi_line.in.hs: -------------------------------------------------------------------------------- 1 | z = (x, y) 2 | where x = [ n * n | n <- [1..] 3 | , odd n 4 | , isPrime n ] 5 | y = [ n * n | n <- [1..] 6 | , even n 7 | , isPrime (n `div` 2) ] 8 | -------------------------------------------------------------------------------- /test/list/comprehension_multi_line.out.hs: -------------------------------------------------------------------------------- 1 | z = (x, y) 2 | where x = [ n * n | n <- [1..] 3 | , odd n 4 | , isPrime n ] 5 | y = [ n * n | n <- [1..] 6 | , even n 7 | , isPrime (n `div` 2) ] 8 | -------------------------------------------------------------------------------- /test/list/comprehension_multi_line2.in.hs: -------------------------------------------------------------------------------- 1 | z = (x, y) 2 | where x = [ n * n 3 | | n <- [1..] 4 | , odd n 5 | , isPrime n ] 6 | y = [ n * n 7 | | n <- [1..] 8 | , even n 9 | , isPrime (n `div` 2) ] 10 | -------------------------------------------------------------------------------- /test/list/comprehension_multi_line2.out.hs: -------------------------------------------------------------------------------- 1 | z = (x, y) 2 | where x = [ n * n 3 | | n <- [1..] 4 | , odd n 5 | , isPrime n ] 6 | y = [ n * n 7 | | n <- [1..] 8 | , even n 9 | , isPrime (n `div` 2) ] 10 | -------------------------------------------------------------------------------- /test/list/comprehension_multi_line3.in.hs: -------------------------------------------------------------------------------- 1 | z = (x, y) 2 | where x = [ n * n 3 | | n <- ns, 4 | odd n, 5 | isPrime n ] 6 | y = [ n * n | n <- [1..], 7 | even n, 8 | let z = n, 9 | isPrime (z `div` 2) ] 10 | -------------------------------------------------------------------------------- /test/list/comprehension_multi_line3.out.hs: -------------------------------------------------------------------------------- 1 | z = (x, y) 2 | where x = [ n * n 3 | | n <- ns, 4 | odd n, 5 | isPrime n ] 6 | y = [ n * n | n <- [1..], 7 | even n, 8 | let z = n, 9 | isPrime (z `div` 2) ] 10 | -------------------------------------------------------------------------------- /test/list/comprenesion.in.hs: -------------------------------------------------------------------------------- 1 | z = (x, y) 2 | where x = [ (i, j) | i <- [0..10], j <- [0..10] ] 3 | y = [ (i, j) | i <- [0..10], j <- [0..10] ] 4 | -------------------------------------------------------------------------------- /test/list/comprenesion.out.hs: -------------------------------------------------------------------------------- 1 | z = (x, y) 2 | where x = [ (i, j) | i <- [0..10], j <- [0..10] ] 3 | y = [ (i, j) | i <- [0..10], j <- [0..10] ] 4 | -------------------------------------------------------------------------------- /test/list/list.in.hs: -------------------------------------------------------------------------------- 1 | z = (x, y) 2 | where x = [ 1, 2, 3 ] 3 | y = [ 1, 2, 3 ] 4 | -------------------------------------------------------------------------------- /test/list/list.out.hs: -------------------------------------------------------------------------------- 1 | z = (x, y) 2 | where x = [ 1, 2, 3 ] 3 | y = [ 1, 2, 3 ] 4 | -------------------------------------------------------------------------------- /test/list/list_parenthesis.in.hs: -------------------------------------------------------------------------------- 1 | z = (x, y) 2 | where x = [ (1, 2), 3 | (3, 4), 4 | (5, 6) ] 5 | y = [ (7, 8), 6 | (9, 10) ] 7 | (z, w) = (0, 0) 8 | 9 | 10 | f x = [ (1, 2), 11 | (3, 4), 12 | (5, 6) ] 13 | -------------------------------------------------------------------------------- /test/list/list_parenthesis.out.hs: -------------------------------------------------------------------------------- 1 | z = (x, y) 2 | where x = [ (1, 2), 3 | (3, 4), 4 | (5, 6) ] 5 | y = [ (7, 8), 6 | (9, 10) ] 7 | (z, w) = (0, 0) 8 | 9 | 10 | f x = [ (1, 2), 11 | (3, 4), 12 | (5, 6) ] 13 | -------------------------------------------------------------------------------- /test/list/multi.in.hs: -------------------------------------------------------------------------------- 1 | z = (x, y) 2 | where x = [ [ 1, 2, 3 ], 3 | [ 4, 5, 6 ], 4 | [ 7, 8, 9 ] ] 5 | y = [ [ 1, 2, 3 ], 6 | [ 4, 5, 6 ] ] 7 | 8 | 9 | f x = 10 10 | -------------------------------------------------------------------------------- /test/list/multi.out.hs: -------------------------------------------------------------------------------- 1 | z = (x, y) 2 | where x = [ [ 1, 2, 3 ], 3 | [ 4, 5, 6 ], 4 | [ 7, 8, 9 ] ] 5 | y = [ [ 1, 2, 3 ], 6 | [ 4, 5, 6 ] ] 7 | 8 | 9 | f x = 10 10 | -------------------------------------------------------------------------------- /test/list/multi_comma.in.hs: -------------------------------------------------------------------------------- 1 | z = (x, y) 2 | where x = [ [ 1, 2, 3 ] 3 | , [ 4, 5, 6 ] 4 | , [ 7, 8, 9 ] ] 5 | y = [ [ 1, 2, 3 ] 6 | , [ 4, 5, 6 ] ] 7 | 8 | 9 | f x = 10 10 | -------------------------------------------------------------------------------- /test/list/multi_comma.out.hs: -------------------------------------------------------------------------------- 1 | z = (x, y) 2 | where x = [ [ 1, 2, 3 ] 3 | , [ 4, 5, 6 ] 4 | , [ 7, 8, 9 ] ] 5 | y = [ [ 1, 2, 3 ] 6 | , [ 4, 5, 6 ] ] 7 | 8 | 9 | f x = 10 10 | -------------------------------------------------------------------------------- /test/macro/guard.in.hs: -------------------------------------------------------------------------------- 1 | f = g 2 | where 3 | #ifdef X 4 | g _ _ = 1 5 | #else 6 | g p x 7 | | p x = 2 8 | | otherwise = 3 9 | #endif 10 | -------------------------------------------------------------------------------- /test/macro/guard.out.hs: -------------------------------------------------------------------------------- 1 | f = g 2 | where 3 | #ifdef X 4 | g _ _ = 1 5 | #else 6 | g p x 7 | | p x = 2 8 | | otherwise = 3 9 | #endif 10 | -------------------------------------------------------------------------------- /test/macro/macro.in.hs: -------------------------------------------------------------------------------- 1 | #if MIN_VERSION_base(4,8,0) 2 | import Control.Applicative ((<$>)) 3 | #else 4 | import Control.Applicative (Applicative(..), (<$>)) 5 | import Data.Monoid (Monoid(..)) 6 | import Data.Traversable (Traversable(traverse)) 7 | #endif 8 | #if __GLASGOW_HASKELL__ 9 | import GHC.Exts ( build ) 10 | #endif 11 | #if __GLASGOW_HASKELL__ >= 708 12 | import qualified GHC.Exts as GHCExts 13 | #endif 14 | -------------------------------------------------------------------------------- /test/macro/macro.out.hs: -------------------------------------------------------------------------------- 1 | #if MIN_VERSION_base(4,8,0) 2 | import Control.Applicative ((<$>)) 3 | #else 4 | import Control.Applicative (Applicative(..), (<$>)) 5 | import Data.Monoid (Monoid(..)) 6 | import Data.Traversable (Traversable(traverse)) 7 | #endif 8 | #if __GLASGOW_HASKELL__ 9 | import GHC.Exts ( build ) 10 | #endif 11 | #if __GLASGOW_HASKELL__ >= 708 12 | import qualified GHC.Exts as GHCExts 13 | #endif 14 | -------------------------------------------------------------------------------- /test/macro/module_export.in.hs: -------------------------------------------------------------------------------- 1 | module X ( 2 | foo, 3 | #if __GLASGOW_HASKELL__ 4 | bar, 5 | #endif 6 | #if __GLASGOW_HASKELL__ >= 708 7 | baz 8 | #endif 9 | ) where 10 | -------------------------------------------------------------------------------- /test/macro/module_export.out.hs: -------------------------------------------------------------------------------- 1 | module X ( 2 | foo, 3 | #if __GLASGOW_HASKELL__ 4 | bar, 5 | #endif 6 | #if __GLASGOW_HASKELL__ >= 708 7 | baz 8 | #endif 9 | ) where 10 | -------------------------------------------------------------------------------- /test/macro/module_export_with_comment.in.hs: -------------------------------------------------------------------------------- 1 | module X ( 2 | -- foo 3 | foo, 4 | #if __GLASGOW_HASKELL__ 5 | -- bar 6 | bar, 7 | #endif 8 | #if __GLASGOW_HASKELL__ >= 708 9 | -- baz 10 | baz 11 | #endif 12 | ) where 13 | -------------------------------------------------------------------------------- /test/macro/module_export_with_comment.out.hs: -------------------------------------------------------------------------------- 1 | module X ( 2 | -- foo 3 | foo, 4 | #if __GLASGOW_HASKELL__ 5 | -- bar 6 | bar, 7 | #endif 8 | #if __GLASGOW_HASKELL__ >= 708 9 | -- baz 10 | baz 11 | #endif 12 | ) where 13 | -------------------------------------------------------------------------------- /test/module/export.in.hs: -------------------------------------------------------------------------------- 1 | module X (foo) where 2 | foo = 10 3 | -------------------------------------------------------------------------------- /test/module/export.out.hs: -------------------------------------------------------------------------------- 1 | module X (foo) where 2 | foo = 10 3 | -------------------------------------------------------------------------------- /test/module/export_comma_first.in.hs: -------------------------------------------------------------------------------- 1 | module X 2 | ( 3 | #if !defined(TESTING) 4 | X 5 | #else 6 | X(..) 7 | #endif 8 | 9 | -- f 10 | , f 11 | 12 | -- g 13 | , g 14 | 15 | , h 16 | ) where 17 | import Y 18 | -------------------------------------------------------------------------------- /test/module/export_comma_first.out.hs: -------------------------------------------------------------------------------- 1 | module X 2 | ( 3 | #if !defined(TESTING) 4 | X 5 | #else 6 | X(..) 7 | #endif 8 | 9 | -- f 10 | , f 11 | 12 | -- g 13 | , g 14 | 15 | , h 16 | ) where 17 | import Y 18 | -------------------------------------------------------------------------------- /test/module/export_lines.in.hs: -------------------------------------------------------------------------------- 1 | module X ( foo, 2 | bar, 3 | baz ) where 4 | foo = 10 5 | -------------------------------------------------------------------------------- /test/module/export_lines.out.hs: -------------------------------------------------------------------------------- 1 | module X ( foo, 2 | bar, 3 | baz ) where 4 | foo = 10 5 | -------------------------------------------------------------------------------- /test/module/export_lines_enter.in.hs: -------------------------------------------------------------------------------- 1 | module X 2 | ( 3 | foo, 4 | 5 | bar, 6 | 7 | baz 8 | ) where 9 | foo = 10 10 | -------------------------------------------------------------------------------- /test/module/export_lines_enter.out.hs: -------------------------------------------------------------------------------- 1 | module X 2 | ( 3 | foo, 4 | 5 | bar, 6 | 7 | baz 8 | ) where 9 | foo = 10 10 | -------------------------------------------------------------------------------- /test/module/export_lines_enter_paren.in.hs: -------------------------------------------------------------------------------- 1 | module X ( 2 | foo, 3 | 4 | bar, 5 | 6 | baz 7 | ) where 8 | foo = 10 9 | -------------------------------------------------------------------------------- /test/module/export_lines_enter_paren.out.hs: -------------------------------------------------------------------------------- 1 | module X ( 2 | foo, 3 | 4 | bar, 5 | 6 | baz 7 | ) where 8 | foo = 10 9 | -------------------------------------------------------------------------------- /test/module/export_lines_paren_where.in.hs: -------------------------------------------------------------------------------- 1 | module X ( foo, 2 | bar, 3 | baz 4 | ) where 5 | foo = 10 6 | -------------------------------------------------------------------------------- /test/module/export_lines_paren_where.out.hs: -------------------------------------------------------------------------------- 1 | module X ( foo, 2 | bar, 3 | baz 4 | ) where 5 | foo = 10 6 | -------------------------------------------------------------------------------- /test/module/export_lines_where.in.hs: -------------------------------------------------------------------------------- 1 | module X ( foo, 2 | bar, 3 | baz ) 4 | where 5 | foo = 10 6 | -------------------------------------------------------------------------------- /test/module/export_lines_where.out.hs: -------------------------------------------------------------------------------- 1 | module X ( foo, 2 | bar, 3 | baz ) 4 | where 5 | foo = 10 6 | -------------------------------------------------------------------------------- /test/module/export_module.in.hs: -------------------------------------------------------------------------------- 1 | module X 2 | ( 3 | module Y, 4 | module Z 5 | ) 6 | where 7 | import W 8 | -------------------------------------------------------------------------------- /test/module/export_module.out.hs: -------------------------------------------------------------------------------- 1 | module X 2 | ( 3 | module Y, 4 | module Z 5 | ) 6 | where 7 | import W 8 | -------------------------------------------------------------------------------- /test/module/export_module_comment.in.hs: -------------------------------------------------------------------------------- 1 | module X 2 | ( 3 | -- Y 4 | module Y, 5 | -- Z 6 | module Z 7 | ) 8 | where 9 | import W 10 | -------------------------------------------------------------------------------- /test/module/export_module_comment.out.hs: -------------------------------------------------------------------------------- 1 | module X 2 | ( 3 | -- Y 4 | module Y, 5 | -- Z 6 | module Z 7 | ) 8 | where 9 | import W 10 | -------------------------------------------------------------------------------- /test/module/export_module_comment_with_line_comment.in.hs: -------------------------------------------------------------------------------- 1 | module X 2 | ( 3 | -- Y 4 | module Y, -- Y 5 | -- Z 6 | module Z -- Z 7 | ) 8 | where 9 | import W 10 | -------------------------------------------------------------------------------- /test/module/export_module_comment_with_line_comment.out.hs: -------------------------------------------------------------------------------- 1 | module X 2 | ( 3 | -- Y 4 | module Y, -- Y 5 | -- Z 6 | module Z -- Z 7 | ) 8 | where 9 | import W 10 | -------------------------------------------------------------------------------- /test/module/import_comma_first.in.hs: -------------------------------------------------------------------------------- 1 | import X 2 | ( 3 | #if !defined(TESTING) 4 | X 5 | #else 6 | X(..) 7 | #endif 8 | 9 | -- f 10 | , f 11 | 12 | -- g 13 | , g 14 | 15 | , h 16 | ) 17 | import Y 18 | -------------------------------------------------------------------------------- /test/module/import_comma_first.out.hs: -------------------------------------------------------------------------------- 1 | import X 2 | ( 3 | #if !defined(TESTING) 4 | X 5 | #else 6 | X(..) 7 | #endif 8 | 9 | -- f 10 | , f 11 | 12 | -- g 13 | , g 14 | 15 | , h 16 | ) 17 | import Y 18 | -------------------------------------------------------------------------------- /test/module/module.in.hs: -------------------------------------------------------------------------------- 1 | module X where 2 | f x = 10 3 | -------------------------------------------------------------------------------- /test/module/module.out.hs: -------------------------------------------------------------------------------- 1 | module X where 2 | f x = 10 3 | -------------------------------------------------------------------------------- /test/parenthesis/after_let.in.hs: -------------------------------------------------------------------------------- 1 | foo a b = 2 | let (c, d) = f a b 3 | (e, f) = g c d 4 | in f e 5 | -------------------------------------------------------------------------------- /test/parenthesis/after_let.out.hs: -------------------------------------------------------------------------------- 1 | foo a b = 2 | let (c, d) = f a b 3 | (e, f) = g c d 4 | in f e 5 | -------------------------------------------------------------------------------- /test/parenthesis/backtick_last.in.hs: -------------------------------------------------------------------------------- 1 | let f x y z = x `foo` 2 | y `bar` 3 | z 4 | -------------------------------------------------------------------------------- /test/parenthesis/backtick_last.out.hs: -------------------------------------------------------------------------------- 1 | let f x y z = x `foo` 2 | y `bar` 3 | z 4 | -------------------------------------------------------------------------------- /test/parenthesis/closed_binding.in.hs: -------------------------------------------------------------------------------- 1 | f x y z 2 | = [ x, 3 | y, 4 | z ] 5 | g x = x 6 | -------------------------------------------------------------------------------- /test/parenthesis/closed_binding.out.hs: -------------------------------------------------------------------------------- 1 | f x y z 2 | = [ x, 3 | y, 4 | z ] 5 | g x = x 6 | -------------------------------------------------------------------------------- /test/parenthesis/closing_parenthesis.in.hs: -------------------------------------------------------------------------------- 1 | let foo = Foo { 2 | foo = 100, 3 | bar = Bar { 4 | bar = 200 5 | }, 6 | baz = [ 7 | 1, 8 | 2, 9 | 3 10 | ], 11 | qux = Qux { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/parenthesis/closing_parenthesis.out.hs: -------------------------------------------------------------------------------- 1 | let foo = Foo { 2 | foo = 100, 3 | bar = Bar { 4 | bar = 200 5 | }, 6 | baz = [ 7 | 1, 8 | 2, 9 | 3 10 | ], 11 | qux = Qux { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/parenthesis/let_parenthesis.in.hs: -------------------------------------------------------------------------------- 1 | f = do 2 | let x = Foo { foo: 1, 3 | bar: 2 } 4 | y <- return 0 5 | return (x, y) 6 | -------------------------------------------------------------------------------- /test/parenthesis/let_parenthesis.out.hs: -------------------------------------------------------------------------------- 1 | f = do 2 | let x = Foo { foo: 1, 3 | bar: 2 } 4 | y <- return 0 5 | return (x, y) 6 | -------------------------------------------------------------------------------- /test/parenthesis/open_parenthesis.in.hs: -------------------------------------------------------------------------------- 1 | let f x y z = X [ 2 | x, 3 | y, 4 | z 5 | ] 6 | -------------------------------------------------------------------------------- /test/parenthesis/open_parenthesis.out.hs: -------------------------------------------------------------------------------- 1 | let f x y z = X [ 2 | x, 3 | y, 4 | z 5 | ] 6 | -------------------------------------------------------------------------------- /test/parenthesis/open_parenthesis_tuple.in.hs: -------------------------------------------------------------------------------- 1 | let f = Foo { 2 | foo = [ 3 | (0, 1), 4 | (1, 2), 5 | (2, 3) 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /test/parenthesis/open_parenthesis_tuple.out.hs: -------------------------------------------------------------------------------- 1 | let f = Foo { 2 | foo = [ 3 | (0, 1), 4 | (1, 2), 5 | (2, 3) 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /test/parenthesis/operator_definition.in.hs: -------------------------------------------------------------------------------- 1 | -- foo bar 2 | (<>) x y = x + y 3 | (++) x y = x * y 4 | -------------------------------------------------------------------------------- /test/parenthesis/operator_definition.out.hs: -------------------------------------------------------------------------------- 1 | -- foo bar 2 | (<>) x y = x + y 3 | (++) x y = x * y 4 | -------------------------------------------------------------------------------- /test/parenthesis/operator_last.in.hs: -------------------------------------------------------------------------------- 1 | let f x y z = x + 2 | y + 3 | z 4 | -------------------------------------------------------------------------------- /test/parenthesis/operator_last.out.hs: -------------------------------------------------------------------------------- 1 | let f x y z = x + 2 | y + 3 | z 4 | -------------------------------------------------------------------------------- /test/parenthesis/operator_type_annotation.in.hs: -------------------------------------------------------------------------------- 1 | (<>) :: a -> a -> a 2 | (<>) x y = x + y 3 | -------------------------------------------------------------------------------- /test/parenthesis/operator_type_annotation.out.hs: -------------------------------------------------------------------------------- 1 | (<>) :: a -> a -> a 2 | (<>) x y = x + y 3 | -------------------------------------------------------------------------------- /test/parenthesis/where.in.hs: -------------------------------------------------------------------------------- 1 | g = f 2 | where f x = [ y | y <- [s..x] ] 3 | s = 0 + 4 | (1) + 5 | (2 + 3) 6 | -------------------------------------------------------------------------------- /test/parenthesis/where.out.hs: -------------------------------------------------------------------------------- 1 | g = f 2 | where f x = [ y | y <- [s..x] ] 3 | s = 0 + 4 | (1) + 5 | (2 + 3) 6 | -------------------------------------------------------------------------------- /test/parenthesis/where_guard.in.hs: -------------------------------------------------------------------------------- 1 | g = f 2 | where f x | x > 10 = [ y | y <- [s..x] ] 3 | | otherwise = [] 4 | s = 0 5 | -------------------------------------------------------------------------------- /test/parenthesis/where_guard.out.hs: -------------------------------------------------------------------------------- 1 | g = f 2 | where f x | x > 10 = [ y | y <- [s..x] ] 3 | | otherwise = [] 4 | s = 0 5 | -------------------------------------------------------------------------------- /test/pragma/indented.in.hs: -------------------------------------------------------------------------------- 1 | f x = q 2 | where q = w 3 | {-# RULES 4 | "q" 5 | #-} 6 | -------------------------------------------------------------------------------- /test/pragma/indented.out.hs: -------------------------------------------------------------------------------- 1 | f x = q 2 | where q = w 3 | {-# RULES 4 | "q" 5 | #-} 6 | -------------------------------------------------------------------------------- /test/pragma/inline.in.hs: -------------------------------------------------------------------------------- 1 | instance X Y where 2 | {-# INLINE foo #-} 3 | foo = 0 4 | -------------------------------------------------------------------------------- /test/pragma/inline.out.hs: -------------------------------------------------------------------------------- 1 | instance X Y where 2 | {-# INLINE foo #-} 3 | foo = 0 4 | -------------------------------------------------------------------------------- /test/pragma/pragma.in.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE X, 2 | Y, 3 | Z #-} 4 | {-# LANGUAGE X 5 | , Y 6 | , Z #-} 7 | {-# LANGUAGE X, 8 | Y, 9 | Z 10 | a#-} 11 | {-# LANGUAGE X 12 | , Y 13 | , Z 14 | a#-} 15 | {-# LANGUAGE A #-} 16 | {-# LANGUAGE B #-} 17 | {-# LANGUAGE C #-} 18 | -------------------------------------------------------------------------------- /test/pragma/pragma.out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE X, 2 | Y, 3 | Z #-} 4 | {-# LANGUAGE X 5 | , Y 6 | , Z #-} 7 | {-# LANGUAGE X, 8 | Y, 9 | Z 10 | #-} 11 | {-# LANGUAGE X 12 | , Y 13 | , Z 14 | #-} 15 | {-# LANGUAGE A #-} 16 | {-# LANGUAGE B #-} 17 | {-# LANGUAGE C #-} 18 | -------------------------------------------------------------------------------- /test/pragma/toplevel.in.hs: -------------------------------------------------------------------------------- 1 | f x = q 2 | where q = w 3 | 4 | g x = q 5 | {-# RULES 6 | "f/g" 7 | #-} 8 | -------------------------------------------------------------------------------- /test/pragma/toplevel.out.hs: -------------------------------------------------------------------------------- 1 | f x = q 2 | where q = w 3 | 4 | g x = q 5 | {-# RULES 6 | "f/g" 7 | #-} 8 | -------------------------------------------------------------------------------- /test/pragma/unpack.in.hs: -------------------------------------------------------------------------------- 1 | data T = T {-# UNPACK #-} !X 2 | {-# UNPACK #-} !X 3 | -------------------------------------------------------------------------------- /test/pragma/unpack.out.hs: -------------------------------------------------------------------------------- 1 | data T = T {-# UNPACK #-} !X 2 | {-# UNPACK #-} !X 3 | -------------------------------------------------------------------------------- /test/recordtype/after_deriving.in.hs: -------------------------------------------------------------------------------- 1 | data X = X { foo :: Int, 2 | bar :: String 3 | } deriving Eq 4 | f x = x 5 | -------------------------------------------------------------------------------- /test/recordtype/after_deriving.out.hs: -------------------------------------------------------------------------------- 1 | data X = X { foo :: Int, 2 | bar :: String 3 | } deriving Eq 4 | f x = x 5 | -------------------------------------------------------------------------------- /test/recordtype/after_deriving_lines.in.hs: -------------------------------------------------------------------------------- 1 | data X = X { foo :: Int, 2 | bar :: String 3 | } deriving ( Eq, 4 | Ord, 5 | Show ) 6 | f x = x 7 | -------------------------------------------------------------------------------- /test/recordtype/after_deriving_lines.out.hs: -------------------------------------------------------------------------------- 1 | data X = X { foo :: Int, 2 | bar :: String 3 | } deriving ( Eq, 4 | Ord, 5 | Show ) 6 | f x = x 7 | -------------------------------------------------------------------------------- /test/recordtype/after_deriving_lines_comma_first.in.hs: -------------------------------------------------------------------------------- 1 | data X = X { foo :: Int, 2 | bar :: String 3 | } deriving ( Eq 4 | , Ord 5 | , Show ) 6 | f x = x 7 | -------------------------------------------------------------------------------- /test/recordtype/after_deriving_lines_comma_first.out.hs: -------------------------------------------------------------------------------- 1 | data X = X { foo :: Int, 2 | bar :: String 3 | } deriving ( Eq 4 | , Ord 5 | , Show ) 6 | f x = x 7 | -------------------------------------------------------------------------------- /test/recordtype/after_deriving_parenthesis.in.hs: -------------------------------------------------------------------------------- 1 | data X = X { foo :: Int, 2 | bar :: String, 3 | } deriving (Eq, Show, Ord) 4 | f x = x 5 | -------------------------------------------------------------------------------- /test/recordtype/after_deriving_parenthesis.out.hs: -------------------------------------------------------------------------------- 1 | data X = X { foo :: Int, 2 | bar :: String, 3 | } deriving (Eq, Show, Ord) 4 | f x = x 5 | -------------------------------------------------------------------------------- /test/recordtype/coomma_first_after_deriving_lines_comma_first.in.hs: -------------------------------------------------------------------------------- 1 | data X = X { foo :: Int 2 | , bar :: String 3 | } deriving ( Eq 4 | , Ord 5 | , Show ) 6 | f x = x 7 | -------------------------------------------------------------------------------- /test/recordtype/coomma_first_after_deriving_lines_comma_first.out.hs: -------------------------------------------------------------------------------- 1 | data X = X { foo :: Int 2 | , bar :: String 3 | } deriving ( Eq 4 | , Ord 5 | , Show ) 6 | f x = x 7 | -------------------------------------------------------------------------------- /test/recordtype/eq_first.in.hs: -------------------------------------------------------------------------------- 1 | data X 2 | = X { 3 | foo :: Int, 4 | bar :: String 5 | } deriving (Eq, Ord Show) 6 | f x = x 7 | -------------------------------------------------------------------------------- /test/recordtype/eq_first.out.hs: -------------------------------------------------------------------------------- 1 | data X 2 | = X { 3 | foo :: Int, 4 | bar :: String 5 | } deriving (Eq, Ord Show) 6 | f x = x 7 | -------------------------------------------------------------------------------- /test/recordtype/newline_record.in.hs: -------------------------------------------------------------------------------- 1 | data X = 2 | X { 3 | foo :: Int, 4 | bar :: String 5 | } deriving (Eq, Ord Show) 6 | f x = x 7 | -------------------------------------------------------------------------------- /test/recordtype/newline_record.out.hs: -------------------------------------------------------------------------------- 1 | data X = 2 | X { 3 | foo :: Int, 4 | bar :: String 5 | } deriving (Eq, Ord Show) 6 | f x = x 7 | -------------------------------------------------------------------------------- /test/recordtype/no_newline.in.hs: -------------------------------------------------------------------------------- 1 | data X = X { foo :: Int, bar :: String } 2 | deriving Eq 3 | -------------------------------------------------------------------------------- /test/recordtype/no_newline.out.hs: -------------------------------------------------------------------------------- 1 | data X = X { foo :: Int, bar :: String } 2 | deriving Eq 3 | -------------------------------------------------------------------------------- /test/recordtype/record.in.hs: -------------------------------------------------------------------------------- 1 | data X = X { foo :: Int 2 | , bar :: String 3 | } deriving Eq 4 | -------------------------------------------------------------------------------- /test/recordtype/record.out.hs: -------------------------------------------------------------------------------- 1 | data X = X { foo :: Int 2 | , bar :: String 3 | } deriving Eq 4 | -------------------------------------------------------------------------------- /test/recordtype/record_newline.in.hs: -------------------------------------------------------------------------------- 1 | data X = X { 2 | foo :: Int, 3 | bar :: String 4 | } deriving Eq 5 | f x = x 6 | -------------------------------------------------------------------------------- /test/recordtype/record_newline.out.hs: -------------------------------------------------------------------------------- 1 | data X = X { 2 | foo :: Int, 3 | bar :: String 4 | } deriving Eq 5 | f x = x 6 | -------------------------------------------------------------------------------- /test/recordtype/record_newline_deriving.in.hs: -------------------------------------------------------------------------------- 1 | data X = X { 2 | foo :: Int, 3 | bar :: String 4 | } deriving ( Eq 5 | , Ord 6 | , Show ) 7 | f x = x 8 | -------------------------------------------------------------------------------- /test/recordtype/record_newline_deriving.out.hs: -------------------------------------------------------------------------------- 1 | data X = X { 2 | foo :: Int, 3 | bar :: String 4 | } deriving ( Eq 5 | , Ord 6 | , Show ) 7 | f x = x 8 | -------------------------------------------------------------------------------- /test/test.vim: -------------------------------------------------------------------------------- 1 | let s:assert = themis#helper('assert') 2 | 3 | function! s:test(path) 4 | for path in filter(split(glob(a:path . '/*')), 'isdirectory(v:val)') 5 | let suite = themis#suite('Test for ' . matchstr(path, '\w*$')) 6 | function! suite.before() abort 7 | filetype plugin indent on 8 | setlocal filetype=haskell 9 | setlocal formatoptions-=cro 10 | endfunction 11 | function! suite.before_each() abort 12 | % delete _ 13 | setlocal expandtab shiftwidth=2 14 | let g:haskell_indent_disable_case = 0 15 | endfunction 16 | for infile in split(glob(path . '/*.in.hs', 1), "\n") 17 | execute join([ 18 | \ 'function! suite.' . matchstr(infile, '\w*\ze\.in\.hs$') . '()' 19 | \,' let infile = ' . string(infile) 20 | \,' let result = ' . string(substitute(infile, '\.\zsin\ze\.hs$', 'out', '')) 21 | \,' execute "normal! i" . substitute(join(readfile(infile), ""),' 22 | \.' ''<\a*>'', ''\=eval(''''"\''''.submatch(0).''''"'''')'', ''g'')' 23 | \,' call s:assert.equals(getline(1, line("$")), readfile(result))' 24 | \,' normal! ggvG100:p:h')) 42 | -------------------------------------------------------------------------------- /test/typesig/typesig.in.hs: -------------------------------------------------------------------------------- 1 | foo :: 2 | Int 3 | -> Int 4 | foo = bar 5 | -------------------------------------------------------------------------------- /test/typesig/typesig.out.hs: -------------------------------------------------------------------------------- 1 | foo :: 2 | Int 3 | -> Int 4 | foo = bar 5 | -------------------------------------------------------------------------------- /test/where/after_guard.in.hs: -------------------------------------------------------------------------------- 1 | f x | x > 10 = 10 2 | | x < 0 = 0 3 | | otherwise = x 4 | where y = 10 5 | z = 10 6 | 7 | g x = 10 8 | -------------------------------------------------------------------------------- /test/where/after_guard.out.hs: -------------------------------------------------------------------------------- 1 | f x | x > 10 = 10 2 | | x < 0 = 0 3 | | otherwise = x 4 | where y = 10 5 | z = 10 6 | 7 | g x = 10 8 | -------------------------------------------------------------------------------- /test/where/block.in.hs: -------------------------------------------------------------------------------- 1 | x = y 2 | where y = 10 3 | z = 10 4 | -------------------------------------------------------------------------------- /test/where/block.out.hs: -------------------------------------------------------------------------------- 1 | x = y 2 | where y = 10 3 | z = 10 4 | -------------------------------------------------------------------------------- /test/where/multiple.in.hs: -------------------------------------------------------------------------------- 1 | x = y 2 | where 3 | y = z 4 | where z = 10 5 | -------------------------------------------------------------------------------- /test/where/multiple.out.hs: -------------------------------------------------------------------------------- 1 | x = y 2 | where 3 | y = z 4 | where z = 10 5 | -------------------------------------------------------------------------------- /test/where/multiple_after_guard.in.hs: -------------------------------------------------------------------------------- 1 | x = y 2 | where 3 | y | False = z 4 | | otherwise = 0 5 | where z = 10 6 | -------------------------------------------------------------------------------- /test/where/multiple_after_guard.out.hs: -------------------------------------------------------------------------------- 1 | x = y 2 | where 3 | y | False = z 4 | | otherwise = 0 5 | where z = 10 6 | -------------------------------------------------------------------------------- /test/where/no_newline_same_line.in.hs: -------------------------------------------------------------------------------- 1 | x = y where y = z 2 | z = 10 3 | -------------------------------------------------------------------------------- /test/where/no_newline_same_line.out.hs: -------------------------------------------------------------------------------- 1 | x = y where y = z 2 | z = 10 3 | -------------------------------------------------------------------------------- /test/where/no_newline_where.in.hs: -------------------------------------------------------------------------------- 1 | x = y where 2 | y = 10 3 | -------------------------------------------------------------------------------- /test/where/no_newline_where.out.hs: -------------------------------------------------------------------------------- 1 | x = y where 2 | y = 10 3 | -------------------------------------------------------------------------------- /test/where/reindent.in.hs: -------------------------------------------------------------------------------- 1 | x = y 2 | awhere y = 10 3 | -------------------------------------------------------------------------------- /test/where/reindent.out.hs: -------------------------------------------------------------------------------- 1 | x = y 2 | where y = 10 3 | -------------------------------------------------------------------------------- /test/where/reindent_far.in.hs: -------------------------------------------------------------------------------- 1 | f x = q 2 | 3 | 4 | 5 | awhere q = 10 6 | -------------------------------------------------------------------------------- /test/where/reindent_far.out.hs: -------------------------------------------------------------------------------- 1 | f x = q 2 | 3 | 4 | 5 | where q = 10 6 | -------------------------------------------------------------------------------- /test/where/unindent.in.hs: -------------------------------------------------------------------------------- 1 | f x = q 2 | where q = 20 3 | 4 | g x = x 5 | -------------------------------------------------------------------------------- /test/where/unindent.out.hs: -------------------------------------------------------------------------------- 1 | f x = q 2 | where q = 20 3 | 4 | g x = x 5 | -------------------------------------------------------------------------------- /test/where/unindent_multiple.in.hs: -------------------------------------------------------------------------------- 1 | f x = q 2 | where q = z 3 | where z = 10 4 | 5 | p = w 6 | 7 | w = 10 8 | -------------------------------------------------------------------------------- /test/where/unindent_multiple.out.hs: -------------------------------------------------------------------------------- 1 | f x = q 2 | where q = z 3 | where z = 10 4 | 5 | p = w 6 | 7 | w = 10 8 | -------------------------------------------------------------------------------- /test/where/where.in.hs: -------------------------------------------------------------------------------- 1 | x = y 2 | where 3 | y = 10 4 | -------------------------------------------------------------------------------- /test/where/where.out.hs: -------------------------------------------------------------------------------- 1 | x = y 2 | where 3 | y = 10 4 | -------------------------------------------------------------------------------- /test/where/where_eq_newline.in.hs: -------------------------------------------------------------------------------- 1 | f = g 2 | where g = 3 | map 4 | -------------------------------------------------------------------------------- /test/where/where_eq_newline.out.hs: -------------------------------------------------------------------------------- 1 | f = g 2 | where g = 3 | map 4 | -------------------------------------------------------------------------------- /test/where/where_paren.in.hs: -------------------------------------------------------------------------------- 1 | f x = y 0 2 | where y z | z > 10 = 10 3 | | otherwise = (10 + 20) 4 | q = 20 5 | 6 | p = 10 7 | -------------------------------------------------------------------------------- /test/where/where_paren.out.hs: -------------------------------------------------------------------------------- 1 | f x = y 0 2 | where y z | z > 10 = 10 3 | | otherwise = (10 + 20) 4 | q = 20 5 | 6 | p = 10 7 | --------------------------------------------------------------------------------