├── data ├── diff-tests │ ├── inputs │ │ ├── empty.hs │ │ ├── one-line.hs │ │ ├── main.hs │ │ ├── main-foo.hs │ │ ├── main-v2.hs │ │ ├── main-and-foo.hs │ │ ├── main-and-foo-v2.hs │ │ ├── main-and-bar.hs │ │ ├── main-and-bar-v2.hs │ │ ├── spaced-v2.hs │ │ ├── spaced.hs │ │ ├── main-and-baz-v2.hs │ │ └── main-and-baz.hs │ └── outputs │ │ ├── one-line-added.txt │ │ ├── one-line-removed.txt │ │ ├── trimming.txt │ │ ├── no-following.txt │ │ ├── no-preceding.txt │ │ ├── simple-hunk.txt │ │ ├── joined-hunk.txt │ │ └── two-hunks.txt └── examples │ ├── module-header │ ├── empty.hs │ ├── empty-out.hs │ ├── simple-out.hs │ ├── simple.hs │ ├── singleline-out.hs │ ├── singleline.hs │ ├── multiline-empty.hs │ ├── multiline.hs │ ├── multiline2.hs │ ├── multiline-empty-out.hs │ ├── double-shebangs.hs │ ├── double-shebangs-out.hs │ ├── singleline-empty.hs │ ├── multiline-out.hs │ ├── singleline-empty-out.hs │ ├── multiline2-out.hs │ ├── simple-with-comments-out.hs │ ├── simple-with-comments.hs │ ├── warning-pragma.hs │ ├── warning-pragma-singleton-list-out.hs │ ├── warning-pragma-singleton-list.hs │ ├── shebang-with-pragmas-out.hs │ ├── shebang-with-pragmas.hs │ ├── warning-pragma-out.hs │ ├── shebang.hs │ ├── stack-header-0.hs │ ├── shebang-out.hs │ ├── warning-pragma-multiline.hs │ ├── stack-header-0-out.hs │ ├── stack-header-1.hs │ ├── warning-pragma-multiline-out.hs │ ├── preceding-comment-with-haddock.hs │ ├── preceding-comment-with-haddock-out.hs │ ├── stack-header-1-out.hs │ ├── warning-pragma-list-multiline.hs │ ├── named-section.hs │ ├── named-section-out.hs │ ├── warning-pragma-list-multiline-out.hs │ ├── stack-header-2-out.hs │ ├── stack-header-2.hs │ ├── double-dot-with-names.hs │ └── double-dot-with-names-out.hs │ ├── declaration │ ├── data │ │ ├── infix.hs │ │ ├── infix-out.hs │ │ ├── empty.hs │ │ ├── empty-out.hs │ │ ├── with-comment-out.hs │ │ ├── with-comment.hs │ │ ├── deriving.hs │ │ ├── unnamed-field-comment-1.hs │ │ ├── deriving-out.hs │ │ ├── unnamed-field-comment-1-out.hs │ │ ├── gadt-syntax-out.hs │ │ ├── gadt-syntax.hs │ │ ├── gadt │ │ │ ├── multiline-where.hs │ │ │ ├── multiline-where-out.hs │ │ │ ├── strictness.hs │ │ │ ├── strictness-out.hs │ │ │ ├── multiple-declaration.hs │ │ │ ├── record.hs │ │ │ ├── multiple-declaration-out.hs │ │ │ └── record-out.hs │ │ ├── newtype-out.hs │ │ ├── newtype.hs │ │ ├── with-weird-haddock.hs │ │ ├── unnamed-field-comment-0-out.hs │ │ ├── unnamed-field-comment-0.hs │ │ ├── simple-out.hs │ │ ├── simple.hs │ │ ├── with-weird-haddock-out.hs │ │ ├── record-singleline-out.hs │ │ ├── record-singleline.hs │ │ ├── partly-documented.hs │ │ ├── existential.hs │ │ ├── existential-out.hs │ │ ├── partly-documented-out.hs │ │ ├── fat-multiline.hs │ │ ├── field-layout │ │ │ ├── variants.hs │ │ │ ├── gadt.hs │ │ │ ├── variants-out.hs │ │ │ ├── record.hs │ │ │ ├── gadt-out.hs │ │ │ └── record-out.hs │ │ ├── strictness-out.hs │ │ ├── strictness.hs │ │ ├── multiline.hs │ │ ├── fat-multiline-out.hs │ │ ├── simple-broken-out.hs │ │ ├── multiline-arg-parens-out.hs │ │ ├── multiline-out.hs │ │ ├── multiline-arg-parens.hs │ │ ├── simple-broken.hs │ │ ├── record-multi-const.hs │ │ ├── existential-multiline.hs │ │ ├── deriving-strategies.hs │ │ ├── existential-multiline-out.hs │ │ ├── kind-annotations.hs │ │ ├── deriving-strategies-out.hs │ │ ├── kind-annotations-out.hs │ │ └── record-multi-const-out.hs │ ├── value │ │ ├── function │ │ │ ├── prefix.hs │ │ │ ├── backticks.hs │ │ │ ├── builtin-syntax.hs │ │ │ ├── parens.hs │ │ │ ├── prefix-out.hs │ │ │ ├── simple.hs │ │ │ ├── backticks-out.hs │ │ │ ├── builtin-syntax-out.hs │ │ │ ├── parens-out.hs │ │ │ ├── simple-out.hs │ │ │ ├── arg-breakpoints.hs │ │ │ ├── arg-breakpoints-out.hs │ │ │ ├── do-single-multi.hs │ │ │ ├── operators-1.hs │ │ │ ├── do-single-multi-out.hs │ │ │ ├── explicit-type.hs │ │ │ ├── let-nested-out.hs │ │ │ ├── let-nested.hs │ │ │ ├── operators-1-out.hs │ │ │ ├── multiple-matches.hs │ │ │ ├── operators-5.hs │ │ │ ├── explicit-type-out.hs │ │ │ ├── infix │ │ │ │ ├── unicode.hs │ │ │ │ ├── unicode-out.hs │ │ │ │ ├── applicative-out.hs │ │ │ │ ├── applicative.hs │ │ │ │ ├── comments.hs │ │ │ │ ├── comments-out.hs │ │ │ │ ├── do.hs │ │ │ │ ├── do-out.hs │ │ │ │ ├── simple.hs │ │ │ │ ├── simple-out.hs │ │ │ │ ├── hanging.hs │ │ │ │ └── hanging-out.hs │ │ │ ├── multiple-matches-out.hs │ │ │ ├── operators-0.hs │ │ │ ├── tricky-parens-out.hs │ │ │ ├── unboxed-string-lit.hs │ │ │ ├── do-where.hs │ │ │ ├── equality-constraints.hs │ │ │ ├── tricky-parens.hs │ │ │ ├── typed-expressions.hs │ │ │ ├── unboxed-string-lit-out.hs │ │ │ ├── do-where-out.hs │ │ │ ├── equality-constraints-out.hs │ │ │ ├── operators-0-out.hs │ │ │ ├── operators-5-out.hs │ │ │ ├── pattern │ │ │ │ ├── strictness.hs │ │ │ │ ├── strictness-out.hs │ │ │ │ ├── as-pattern.hs │ │ │ │ ├── as-pattern-out.hs │ │ │ │ ├── sig-pattern-out.hs │ │ │ │ ├── sig-pattern.hs │ │ │ │ ├── pattern-bind.hs │ │ │ │ ├── pattern-bind-out.hs │ │ │ │ ├── n-plus-k-pattern.hs │ │ │ │ ├── famous-cardano-pattern.hs │ │ │ │ ├── famous-cardano-pattern-out.hs │ │ │ │ ├── n-plus-k-pattern-out.hs │ │ │ │ ├── quasi-quotes-pattern.hs │ │ │ │ ├── quasi-quotes-pattern-out.hs │ │ │ │ ├── splice-pattern.hs │ │ │ │ ├── splice-pattern-out.hs │ │ │ │ ├── view-pattern.hs │ │ │ │ ├── view-pattern-out.hs │ │ │ │ └── multiline-case-pattern.hs │ │ │ ├── typed-hole.hs │ │ │ ├── operators-2-out.hs │ │ │ ├── operators-2.hs │ │ │ ├── typed-hole-out.hs │ │ │ ├── do │ │ │ │ ├── comment-spacing.hs │ │ │ │ ├── comment-spacing-out.hs │ │ │ │ ├── recursive-do-mdo.hs │ │ │ │ ├── expr.hs │ │ │ │ ├── expr-out.hs │ │ │ │ ├── comment-alignment.hs │ │ │ │ ├── comment-alignment-out.hs │ │ │ │ ├── recursive-do-mdo-out.hs │ │ │ │ ├── hang-rhs-arrow-out.hs │ │ │ │ ├── hang-rhs-arrow.hs │ │ │ │ ├── applications-and-parens.hs │ │ │ │ ├── applications-and-parens-out.hs │ │ │ │ ├── operator-and-parens-out.hs │ │ │ │ ├── operator-and-parens.hs │ │ │ │ ├── recursive-do-rec-out.hs │ │ │ │ └── recursive-do-rec.hs │ │ │ ├── typed-expressions-out.hs │ │ │ ├── operator-comments-2.hs │ │ │ ├── blank-lines-where-out.hs │ │ │ ├── blank-lines-where.hs │ │ │ ├── operators-3.hs │ │ │ ├── blank-lines-let-out.hs │ │ │ ├── multiline-arguments.hs │ │ │ ├── negation-out.hs │ │ │ ├── negation.hs │ │ │ ├── operator-comments-2-out.hs │ │ │ ├── operators-3-out.hs │ │ │ ├── overloaded-labels.hs │ │ │ ├── operators-4-out.hs │ │ │ ├── operators-4.hs │ │ │ ├── overloaded-labels-out.hs │ │ │ ├── blank-lines-let.hs │ │ │ ├── unboxed-tuples.hs │ │ │ ├── list-notation-0.hs │ │ │ ├── tuple-sections-out.hs │ │ │ ├── list-notation-0-out.hs │ │ │ ├── tuple-sections.hs │ │ │ ├── arrow │ │ │ │ ├── multiline-case.hs │ │ │ │ ├── multiline-case-out.hs │ │ │ │ ├── proc-parentheses-out.hs │ │ │ │ ├── proc-lambdas-out.hs │ │ │ │ ├── proc-lambdas.hs │ │ │ │ ├── proc-parentheses.hs │ │ │ │ ├── proc-lets-out.hs │ │ │ │ ├── proc-lets.hs │ │ │ │ ├── proc-ifs.hs │ │ │ │ ├── proc-ifs-out.hs │ │ │ │ ├── recursive-procs.hs │ │ │ │ └── proc-applications.hs │ │ │ ├── strings.hs │ │ │ ├── unboxed-sums.hs │ │ │ ├── if-single-line.hs │ │ │ ├── multiline-arguments-out.hs │ │ │ ├── if-single-line-out.hs │ │ │ ├── record │ │ │ │ ├── hanging-after-equal-con.hs │ │ │ │ ├── hanging-after-equal-update.hs │ │ │ │ ├── inter-comments.hs │ │ │ │ ├── updaters.hs │ │ │ │ ├── hanging-after-equal-con-out.hs │ │ │ │ ├── hanging-after-equal-update-out.hs │ │ │ │ ├── updaters-out.hs │ │ │ │ ├── inter-comments-out.hs │ │ │ │ ├── dot-multiline.hs │ │ │ │ ├── dot-multiline-out.hs │ │ │ │ ├── wildcards.hs │ │ │ │ └── wildcards-out.hs │ │ │ ├── application-0.hs │ │ │ ├── backticks-lhs-out.hs │ │ │ ├── parallel-comprehensions-single-line.hs │ │ │ ├── strings-out.hs │ │ │ ├── type-applications-and-splice-out.hs │ │ │ ├── type-applications-and-splice.hs │ │ │ ├── if-with-comment-out.hs │ │ │ ├── if-with-comment.hs │ │ │ ├── unboxed-tuples-out.hs │ │ │ ├── parallel-comprehensions-single-line-out.hs │ │ │ ├── splice-out.hs │ │ │ ├── splice.hs │ │ │ ├── operator-sections.hs │ │ │ ├── unboxed-sums-out.hs │ │ │ ├── pragmas.hs │ │ │ ├── backticks-lhs.hs │ │ │ ├── operator-sections-out.hs │ │ │ ├── parenthesis-lhs-out.hs │ │ │ ├── parenthesis-lhs.hs │ │ │ ├── application-1.hs │ │ │ ├── tuples.hs │ │ │ ├── application-0-out.hs │ │ │ ├── lambda-case.hs │ │ │ ├── lambda-case-out.hs │ │ │ ├── overindentation.hs │ │ │ ├── tuples-out.hs │ │ │ ├── case-single-line.hs │ │ │ ├── case-single-line-out.hs │ │ │ ├── pragmas-out.hs │ │ │ ├── list-notation-2-out.hs │ │ │ ├── list-notation-2.hs │ │ │ ├── quasi-quotes.hs │ │ │ ├── comprehension │ │ │ │ ├── transform-multi-line1.hs │ │ │ │ ├── transform-multi-line1-out.hs │ │ │ │ ├── transform-multi-line3.hs │ │ │ │ ├── transform-multi-line2.hs │ │ │ │ ├── transform-multi-line3-out.hs │ │ │ │ ├── transform-multi-line2-out.hs │ │ │ │ └── transform-multi-line4.hs │ │ │ ├── application-1-out.hs │ │ │ ├── operators-6.hs │ │ │ ├── operators-6-out.hs │ │ │ ├── quasi-quotes-out.hs │ │ │ ├── overindentation-out.hs │ │ │ ├── multiple-guards.hs │ │ │ ├── where-nested-out.hs │ │ │ ├── multi-way-if.hs │ │ │ ├── where-nested.hs │ │ │ ├── complex-list.hs │ │ │ ├── multiple-guards-out.hs │ │ │ ├── complex-list-out.hs │ │ │ ├── guards.hs │ │ │ ├── awkward-comment-0-out.hs │ │ │ ├── guards-out.hs │ │ │ ├── awkward-comment-0.hs │ │ │ ├── static-pointers.hs │ │ │ ├── multi-way-if-out.hs │ │ │ ├── operator-comments-1-out.hs │ │ │ ├── type-applications.hs │ │ │ ├── arithmetic-sequences.hs │ │ │ ├── operator-comments-1.hs │ │ │ ├── operator-comments-0-out.hs │ │ │ ├── fancy-forall-0.hs │ │ │ ├── fancy-forall-1.hs │ │ │ ├── operator-comments-0.hs │ │ │ ├── awkward-comment-1.hs │ │ │ ├── static-pointers-out.hs │ │ │ ├── newline-single-line-body-out.hs │ │ │ ├── newline-single-line-body.hs │ │ │ ├── lambda-single-line-out.hs │ │ │ ├── lambda-single-line.hs │ │ │ ├── type-applications-out.hs │ │ │ ├── where-out.hs │ │ │ ├── where.hs │ │ │ ├── awkward-comment-1-out.hs │ │ │ ├── list-notation-1-out.hs │ │ │ ├── implicit-params.hs │ │ │ ├── lambda-multi-line1.hs │ │ │ └── list-notation-1.hs │ │ └── other │ │ │ ├── line-single-line.hs │ │ │ ├── line-single-line-out.hs │ │ │ ├── line-multi-line.hs │ │ │ ├── line-multi-line-out.hs │ │ │ ├── comments-get-before-op-out.hs │ │ │ └── comments-get-before-op.hs │ ├── rewrite-rule │ │ ├── empty.hs │ │ ├── empty-out.hs │ │ ├── forall-0.hs │ │ ├── forall-0-out.hs │ │ ├── basic1.hs │ │ ├── basic1-out.hs │ │ └── type-signature.hs │ ├── signature │ │ ├── fixity │ │ │ ├── infix.hs │ │ │ ├── infixr.hs │ │ │ ├── infix-out.hs │ │ │ ├── infixl.hs │ │ │ ├── infixr-out.hs │ │ │ └── infixl-out.hs │ │ ├── type │ │ │ ├── unicode.hs │ │ │ ├── long-function-name-out.hs │ │ │ ├── long-function-name.hs │ │ │ ├── unicode-out.hs │ │ │ ├── context-single-line.hs │ │ │ ├── context-single-line-out.hs │ │ │ ├── infix-promoted-type-constructor-out.hs │ │ │ ├── infix-promoted-type-constructor.hs │ │ │ ├── context-multi-line-out.hs │ │ │ ├── context-multi-line.hs │ │ │ ├── unrelated.hs │ │ │ ├── unrelated-out.hs │ │ │ ├── multi-value.hs │ │ │ ├── multi-value-out.hs │ │ │ └── arguments.hs │ │ ├── inline │ │ │ ├── conlike-out.hs │ │ │ ├── conlike.hs │ │ │ ├── noinline-out.hs │ │ │ ├── inlineable-out.hs │ │ │ ├── noinline.hs │ │ │ ├── inlineable.hs │ │ │ ├── inline-out.hs │ │ │ └── inline.hs │ │ ├── pattern │ │ │ ├── single-line.hs │ │ │ ├── single-line-out.hs │ │ │ └── multiline.hs │ │ ├── complete │ │ │ ├── complete-out.hs │ │ │ └── complete.hs │ │ ├── minimal │ │ │ ├── minimal.hs │ │ │ └── minimal-out.hs │ │ ├── set-cost-centre │ │ │ ├── set-cost-centre-out.hs │ │ │ └── set-cost-centre.hs │ │ ├── standalone-kind-out.hs │ │ └── standalone-kind.hs │ ├── type-families │ │ ├── type-family │ │ │ ├── operator.hs │ │ │ ├── operator-out.hs │ │ │ ├── injective.hs │ │ │ ├── injective-out.hs │ │ │ ├── simple-out.hs │ │ │ ├── simple.hs │ │ │ ├── no-annotation-out.hs │ │ │ └── no-annotation.hs │ │ ├── closed-type-family │ │ │ ├── with-equal-sign-out.hs │ │ │ ├── with-equal-sign.hs │ │ │ ├── no-annotation-out.hs │ │ │ ├── no-annotation.hs │ │ │ ├── with-forall.hs │ │ │ ├── with-forall-out.hs │ │ │ ├── injective.hs │ │ │ ├── simple-out.hs │ │ │ ├── injective-out.hs │ │ │ └── simple.hs │ │ └── data-family │ │ │ ├── no-annotation-out.hs │ │ │ ├── no-annotation.hs │ │ │ ├── simple-out.hs │ │ │ └── simple.hs │ ├── type │ │ ├── lits.hs │ │ ├── lits-out.hs │ │ ├── splice-out.hs │ │ ├── splice.hs │ │ ├── forall.hs │ │ ├── forall-out.hs │ │ ├── type-applications.hs │ │ ├── type-applications-out.hs │ │ ├── misc-kind-signatures-out.hs │ │ ├── misc-kind-signatures.hs │ │ ├── visible-forall.hs │ │ ├── visible-forall-out.hs │ │ ├── promotion-0.hs │ │ ├── promotion-0-out.hs │ │ └── promotion-1.hs │ ├── instance │ │ ├── empty-instance-out.hs │ │ ├── empty-instance.hs │ │ ├── newlines-after-where-out.hs │ │ ├── newlines-after-where.hs │ │ ├── multi-parameter-out.hs │ │ ├── multi-parameter.hs │ │ ├── data-family-instances-newtype.hs │ │ ├── data-family-instances-newtype-out.hs │ │ ├── single-parameter-out.hs │ │ ├── instance-sigs-multiple-out.hs │ │ ├── instance-sigs-multiple.hs │ │ ├── single-parameter.hs │ │ ├── associated-types-out.hs │ │ ├── data-family-instances-gadt.hs │ │ ├── contexts-comments.hs │ │ ├── contexts.hs │ │ ├── instance-sigs-out.hs │ │ ├── associated-types.hs │ │ ├── data-family-instances-gadt-out.hs │ │ ├── contexts-comments-out.hs │ │ ├── instance-sigs.hs │ │ └── contexts-out.hs │ ├── type-synonyms │ │ ├── with-weird-haddock.hs │ │ ├── with-weird-haddock-out.hs │ │ ├── simple-out.hs │ │ ├── simple.hs │ │ ├── multi-line.hs │ │ └── multi-line-out.hs │ ├── default │ │ ├── default-out.hs │ │ └── default.hs │ ├── class │ │ ├── empty-classes.hs │ │ ├── empty-classes-out.hs │ │ ├── newlines-after-where-out.hs │ │ ├── newlines-after-where.hs │ │ ├── poly-kinded-classes.hs │ │ ├── poly-kinded-classes-out.hs │ │ ├── default-signatures-simple-out.hs │ │ ├── default-signatures-simple.hs │ │ ├── type-operators3.hs │ │ ├── super-classes.hs │ │ ├── newlines-and-default-decls-out.hs │ │ ├── default-implementations-out.hs │ │ ├── super-classes-out.hs │ │ ├── newlines-and-default-decls.hs │ │ ├── default-implementations.hs │ │ ├── associated-data1-out.hs │ │ ├── associated-types1-out.hs │ │ ├── associated-types1.hs │ │ ├── associated-data1.hs │ │ ├── type-operators2-out.hs │ │ ├── type-operators2.hs │ │ ├── type-operators3-out.hs │ │ ├── multi-parameters1-out.hs │ │ ├── associated-data2-out.hs │ │ ├── associated-data2.hs │ │ ├── type-operators1.hs │ │ ├── multi-parameters1.hs │ │ ├── type-operators1-out.hs │ │ ├── multi-parameters2-out.hs │ │ └── associated-types2-out.hs │ ├── splice │ │ ├── typed-splice-out.hs │ │ ├── typed-splice.hs │ │ ├── grouped-splices-out.hs │ │ ├── grouped-splices.hs │ │ ├── untyped-splice-out.hs │ │ ├── untyped-splice.hs │ │ ├── quasiquote.hs │ │ ├── quasiquote-out.hs │ │ ├── bracket.hs │ │ ├── bracket-out.hs │ │ ├── quotes-out.hs │ │ ├── quotes.hs │ │ ├── splice-decl-out.hs │ │ └── splice-decl.hs │ ├── warning │ │ ├── warning-multiline.hs │ │ └── warning-multiline-out.hs │ ├── role-annotation │ │ ├── multi-line-out.hs │ │ ├── multi-line.hs │ │ ├── single-line.hs │ │ └── single-line-out.hs │ ├── deriving │ │ ├── overlapping-out.hs │ │ └── overlapping.hs │ ├── annotation │ │ └── annotation-out.hs │ └── foreign │ │ └── foreign-export.hs │ ├── import │ ├── sorted-out.hs │ ├── sorted.hs │ ├── explicit-prelude-out.hs │ ├── explicit-prelude.hs │ ├── merging-0-out.hs │ ├── merging-1-out.hs │ ├── sorted-export-list.hs │ ├── sorted-export-list-out.hs │ ├── comments-per-import.hs │ ├── merging-0.hs │ ├── merging-2-out.hs │ ├── comments-per-import-out.hs │ ├── merging-1.hs │ ├── qualified-prelude.hs │ ├── qualified-prelude-out.hs │ ├── nested-explicit-imports.hs │ ├── comments-inside-imports-out.hs │ ├── merging-2.hs │ ├── explicit-imports-with-comments.hs │ ├── comments-inside-imports.hs │ ├── explicit-imports-with-comments-out.hs │ ├── misc-out.hs │ ├── simple-out.hs │ ├── explicit-imports.hs │ ├── qualified-post-out.hs │ ├── qualified-post.hs │ ├── nested-explicit-imports-out.hs │ ├── deduplication-bug-out.hs │ ├── deduplication-bug.hs │ ├── explicit-imports-out.hs │ ├── simple.hs │ └── misc.hs │ └── other │ ├── inline-comment-0.hs │ ├── inline-comment-0-out.hs │ ├── empty-haddock-out.hs │ ├── comment-before-hanging.hs │ ├── empty-haddock.hs │ ├── comment-before-hanging-out.hs │ ├── comment-multiline-after.hs │ ├── parens-trailing-idempotence.hs │ ├── haddock-sections.hs │ ├── haddock-sections-out.hs │ ├── comment-multiline-after-out.hs │ ├── consequetive-pipe-comments-out.hs │ ├── consequetive-pipe-comments.hs │ ├── pragma-no-header-out.hs │ ├── comment-glued-together.hs │ ├── following-comment-last-0.hs │ ├── multiline-comments-reindent-out.hs │ ├── parens-trailing-idempotence-out.hs │ ├── pragma-no-header.hs │ ├── comment-glued-together-out.hs │ ├── following-comment-last-0-out.hs │ ├── comment-following-preceding-gap.hs │ ├── comment-following-preceding-gap-out.hs │ ├── comment-alignment-out.hs │ ├── comment-trailing-space-out.hs │ ├── comment-trailing-space.hs │ ├── following-comment-last-3.hs │ ├── following-comment-last-3-out.hs │ ├── cpp │ ├── continuation.hs │ ├── continuation-out.hs │ ├── separation-0a.hs │ ├── separation-2a.hs │ ├── separation-0a-out.hs │ ├── separation-2a-out.hs │ ├── separation-0b.hs │ ├── separation-2b.hs │ ├── separation-0b-out.hs │ ├── separation-2b-out.hs │ ├── lonely-hash.hs │ ├── simple-import.hs │ ├── lonely-hash-out.hs │ └── simple-import-out.hs │ ├── following-comment-last-1.hs │ ├── multiple-blank-line-comment.hs │ ├── following-comment-last-1-out.hs │ ├── multiple-blank-line-comment-out.hs │ ├── trailing-whitespace-out.hs │ ├── comment-alignment.hs │ ├── comment-two-blocks-out.hs │ ├── trailing-whitespace.hs │ ├── comment-after-preceding-haddock.hs │ ├── comment-two-blocks.hs │ ├── comment-after-preceding-haddock-out.hs │ ├── multiline-comments-reindent.hs │ ├── pragma-comments-after.hs │ ├── following-comment-last-2-out.hs │ ├── following-comment-last-2.hs │ ├── disabling │ ├── indented-fragment-out.hs │ ├── indented-fragment.hs │ ├── whole-file-out.hs │ ├── whole-file.hs │ ├── single-definition-out.hs │ └── single-definition.hs │ ├── pragma-comments-after-out.hs │ ├── comment-inside-construct-out.hs │ ├── argument-comment.hs │ ├── argument-comment-out.hs │ ├── comment-inside-construct.hs │ ├── overly-indented-out.hs │ ├── ascii.hs │ ├── ascii-out.hs │ ├── pragma-comments-out.hs │ ├── merging-comments-out.hs │ ├── pragma-comments.hs │ ├── empty-forall.hs │ ├── empty-forall-out.hs │ ├── merging-comments.hs │ ├── pragma-sorting-out.hs │ └── pragma-sorting.hs ├── tests └── Spec.hs ├── Setup.hs ├── shell.nix ├── expected-failures ├── pipes.txt ├── idris.txt ├── distributed-process.txt ├── tensorflow.txt └── esqueleto.txt ├── .github └── workflows │ └── build.sh ├── src └── GHC.hs └── region-tests ├── expected-result-9-12.hs ├── src.hs ├── expected-result-6-8.hs ├── expected-result-6-7.hs ├── expected-result-17-18.hs └── expected-result-all.hs /data/diff-tests/inputs/empty.hs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/examples/module-header/empty.hs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/examples/module-header/empty-out.hs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/diff-tests/inputs/one-line.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | -------------------------------------------------------------------------------- /data/examples/module-header/simple-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | -------------------------------------------------------------------------------- /data/examples/module-header/simple.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | -------------------------------------------------------------------------------- /tests/Spec.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS_GHC -F -pgmF hspec-discover #-} 2 | -------------------------------------------------------------------------------- /data/examples/declaration/data/infix.hs: -------------------------------------------------------------------------------- 1 | data Foo a b = a `Foo` b 2 | -------------------------------------------------------------------------------- /data/examples/declaration/data/infix-out.hs: -------------------------------------------------------------------------------- 1 | data Foo a b = a `Foo` b 2 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/prefix.hs: -------------------------------------------------------------------------------- 1 | foo x y = (+) x y 2 | -------------------------------------------------------------------------------- /data/examples/import/sorted-out.hs: -------------------------------------------------------------------------------- 1 | import A 2 | import B 3 | import C 4 | -------------------------------------------------------------------------------- /data/examples/import/sorted.hs: -------------------------------------------------------------------------------- 1 | import B 2 | import A 3 | import C 4 | -------------------------------------------------------------------------------- /data/examples/declaration/rewrite-rule/empty.hs: -------------------------------------------------------------------------------- 1 | {-# RULES 2 | #-} 3 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/backticks.hs: -------------------------------------------------------------------------------- 1 | foo x y = x `bar` y 2 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/builtin-syntax.hs: -------------------------------------------------------------------------------- 1 | x = return () 2 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/parens.hs: -------------------------------------------------------------------------------- 1 | f = p (do foo; bar) baz 2 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/prefix-out.hs: -------------------------------------------------------------------------------- 1 | foo x y = (+) x y 2 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/simple.hs: -------------------------------------------------------------------------------- 1 | bar x = x 2 | baz = x 3 | -------------------------------------------------------------------------------- /data/examples/declaration/rewrite-rule/empty-out.hs: -------------------------------------------------------------------------------- 1 | {-# RULES 2 | 3 | #-} 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/backticks-out.hs: -------------------------------------------------------------------------------- 1 | foo x y = x `bar` y 2 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/builtin-syntax-out.hs: -------------------------------------------------------------------------------- 1 | x = return () 2 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/parens-out.hs: -------------------------------------------------------------------------------- 1 | f = p (do foo; bar) baz 2 | -------------------------------------------------------------------------------- /data/examples/module-header/singleline-out.hs: -------------------------------------------------------------------------------- 1 | module Foo (foo, bar, baz) where 2 | -------------------------------------------------------------------------------- /data/examples/module-header/singleline.hs: -------------------------------------------------------------------------------- 1 | module Foo ( foo, bar, baz ) where 2 | -------------------------------------------------------------------------------- /data/examples/other/inline-comment-0.hs: -------------------------------------------------------------------------------- 1 | x = ({-a-}b, c) 2 | 3 | y = ({-a-}b) 4 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/fixity/infix.hs: -------------------------------------------------------------------------------- 1 | infix 0 2 | infix 9 <^-^> 3 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/simple-out.hs: -------------------------------------------------------------------------------- 1 | bar x = x 2 | 3 | baz = x 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/other/line-single-line.hs: -------------------------------------------------------------------------------- 1 | x :: [Int] 2 | x = [1,2,3] 3 | -------------------------------------------------------------------------------- /data/examples/module-header/multiline-empty.hs: -------------------------------------------------------------------------------- 1 | module Foo ( 2 | ) where 3 | -------------------------------------------------------------------------------- /data/examples/module-header/multiline.hs: -------------------------------------------------------------------------------- 1 | module Foo ( 2 | foo, bar, baz) where 3 | -------------------------------------------------------------------------------- /data/examples/module-header/multiline2.hs: -------------------------------------------------------------------------------- 1 | module Foo ( 2 | foo, bar, baz) where 3 | -------------------------------------------------------------------------------- /data/examples/other/inline-comment-0-out.hs: -------------------------------------------------------------------------------- 1 | x = ({-a-} b, c) 2 | 3 | y = ({-a-} b) 4 | -------------------------------------------------------------------------------- /data/examples/declaration/data/empty.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE EmptyDataDecls #-} 2 | 3 | data Foo 4 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/fixity/infixr.hs: -------------------------------------------------------------------------------- 1 | infixr 8 `Foo` 2 | infixr 0 ***, &&& 3 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/arg-breakpoints.hs: -------------------------------------------------------------------------------- 1 | foo 2 | bar = 3 | body 4 | -------------------------------------------------------------------------------- /data/examples/import/explicit-prelude-out.hs: -------------------------------------------------------------------------------- 1 | import Aaa 2 | import Zzz 3 | import Prelude 4 | -------------------------------------------------------------------------------- /data/examples/import/explicit-prelude.hs: -------------------------------------------------------------------------------- 1 | import Aaa 2 | import Prelude 3 | import Zzz 4 | -------------------------------------------------------------------------------- /data/examples/module-header/multiline-empty-out.hs: -------------------------------------------------------------------------------- 1 | module Foo 2 | ( 3 | ) 4 | where 5 | -------------------------------------------------------------------------------- /data/examples/declaration/data/empty-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE EmptyDataDecls #-} 2 | 3 | data Foo 4 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/fixity/infix-out.hs: -------------------------------------------------------------------------------- 1 | infix 0 2 | 3 | infix 9 <^-^> 4 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/fixity/infixl.hs: -------------------------------------------------------------------------------- 1 | infixl 8 *** 2 | infixl 0 $, *, +, &&, ** 3 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/arg-breakpoints-out.hs: -------------------------------------------------------------------------------- 1 | foo 2 | bar = 3 | body 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do-single-multi.hs: -------------------------------------------------------------------------------- 1 | foo = do (bar 2 | baz) 3 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operators-1.hs: -------------------------------------------------------------------------------- 1 | foo = f 2 | . g 3 | =<< h . i 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/other/line-single-line-out.hs: -------------------------------------------------------------------------------- 1 | x :: [Int] 2 | x = [1, 2, 3] 3 | -------------------------------------------------------------------------------- /data/examples/import/merging-0-out.hs: -------------------------------------------------------------------------------- 1 | import Foo 2 | import Foo (bar, foo) 3 | import Foo as F 4 | -------------------------------------------------------------------------------- /data/examples/import/merging-1-out.hs: -------------------------------------------------------------------------------- 1 | import "bar" Foo (bar) 2 | import "foo" Foo (baz, foo) 3 | -------------------------------------------------------------------------------- /data/examples/import/sorted-export-list.hs: -------------------------------------------------------------------------------- 1 | import Linear.Vector (Additive (..), (*^), (^*)) 2 | -------------------------------------------------------------------------------- /data/examples/module-header/double-shebangs.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env stack 2 | #!/usr/bin/env stack 3 | -------------------------------------------------------------------------------- /data/diff-tests/inputs/main.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | main :: IO () 4 | main = return () 5 | -------------------------------------------------------------------------------- /data/diff-tests/outputs/one-line-added.txt: -------------------------------------------------------------------------------- 1 | TEST 2 | @@ -1,0 +1,1 @@ 3 | + module Main (main) where 4 | -------------------------------------------------------------------------------- /data/examples/declaration/data/with-comment-out.hs: -------------------------------------------------------------------------------- 1 | data A 2 | = B -- C 3 | | -- D 4 | E 5 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/fixity/infixr-out.hs: -------------------------------------------------------------------------------- 1 | infixr 8 `Foo` 2 | 3 | infixr 0 ***, &&& 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do-single-multi-out.hs: -------------------------------------------------------------------------------- 1 | foo = do 2 | (bar 3 | baz) 4 | -------------------------------------------------------------------------------- /data/examples/import/sorted-export-list-out.hs: -------------------------------------------------------------------------------- 1 | import Linear.Vector (Additive (..), (*^), (^*)) 2 | -------------------------------------------------------------------------------- /data/examples/module-header/double-shebangs-out.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env stack 2 | #!/usr/bin/env stack 3 | -------------------------------------------------------------------------------- /data/examples/other/empty-haddock-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | 4 | foo :: Int 5 | foo = 5 6 | -------------------------------------------------------------------------------- /data/diff-tests/inputs/main-foo.hs: -------------------------------------------------------------------------------- 1 | module Main (foo) where 2 | 3 | main :: IO () 4 | main = return () 5 | -------------------------------------------------------------------------------- /data/diff-tests/inputs/main-v2.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | main :: IO () 4 | main = pure () 5 | -------------------------------------------------------------------------------- /data/diff-tests/outputs/one-line-removed.txt: -------------------------------------------------------------------------------- 1 | TEST 2 | @@ -1,1 +1,0 @@ 3 | - module Main (main) where 4 | -------------------------------------------------------------------------------- /data/examples/declaration/data/with-comment.hs: -------------------------------------------------------------------------------- 1 | data A = 2 | B -- C 3 | 4 | -- D 5 | | E 6 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/fixity/infixl-out.hs: -------------------------------------------------------------------------------- 1 | infixl 8 *** 2 | 3 | infixl 0 $, *, +, &&, ** 4 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/type-family/operator.hs: -------------------------------------------------------------------------------- 1 | type family a ! b 2 | type family a . b 3 | -------------------------------------------------------------------------------- /data/examples/declaration/type/lits.hs: -------------------------------------------------------------------------------- 1 | type A = "foo" 2 | 3 | type B = "foo\ 4 | \bar" -> () 5 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/explicit-type.hs: -------------------------------------------------------------------------------- 1 | foo = 5 :: Int 2 | 3 | bar = 5 4 | :: Int 5 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/let-nested-out.hs: -------------------------------------------------------------------------------- 1 | _ = _ 2 | where 3 | _ = [_ | let _ = _] 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/let-nested.hs: -------------------------------------------------------------------------------- 1 | _ = _ 2 | where 3 | _ = [_ | let _ = _] 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operators-1-out.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | f 3 | . g 4 | =<< h . i 5 | -------------------------------------------------------------------------------- /data/examples/module-header/singleline-empty.hs: -------------------------------------------------------------------------------- 1 | -- | This demonstrates a BUG. 2 | module Foo () where 3 | -------------------------------------------------------------------------------- /data/examples/other/comment-before-hanging.hs: -------------------------------------------------------------------------------- 1 | x = Just 2 | -- comment 3 | do 4 | foo 5 | bar 6 | -------------------------------------------------------------------------------- /data/examples/other/empty-haddock.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | 4 | 5 | foo :: Int 6 | foo = 5 7 | -------------------------------------------------------------------------------- /data/examples/declaration/data/deriving.hs: -------------------------------------------------------------------------------- 1 | newtype R r a = R (ReaderT r IO a) 2 | deriving (MonadReader r) 3 | -------------------------------------------------------------------------------- /data/examples/declaration/data/unnamed-field-comment-1.hs: -------------------------------------------------------------------------------- 1 | data X 2 | = B 3 | !Int -- ^ y 4 | C 5 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/empty-instance-out.hs: -------------------------------------------------------------------------------- 1 | instance Typeable Int 2 | 3 | instance Generic Int 4 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/empty-instance.hs: -------------------------------------------------------------------------------- 1 | instance Typeable Int 2 | instance Generic Int where 3 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/multiple-matches.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int 2 | foo 5 = 10 3 | foo _ = 12 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operators-5.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | map bar $ 3 | [ baz 4 | ] ++ quux 5 | -------------------------------------------------------------------------------- /data/examples/import/comments-per-import.hs: -------------------------------------------------------------------------------- 1 | import Foo -- (1) 2 | import Bar -- (2) 3 | import Baz -- (3) 4 | -------------------------------------------------------------------------------- /data/examples/import/merging-0.hs: -------------------------------------------------------------------------------- 1 | import Foo 2 | import Foo (foo) 3 | import Foo (bar) 4 | import Foo as F 5 | -------------------------------------------------------------------------------- /data/examples/import/merging-2-out.hs: -------------------------------------------------------------------------------- 1 | import Foo hiding (bar4, foo2) 2 | import qualified Foo (bar3, foo1) 3 | -------------------------------------------------------------------------------- /data/examples/module-header/multiline-out.hs: -------------------------------------------------------------------------------- 1 | module Foo 2 | ( foo 3 | , bar 4 | , baz 5 | ) 6 | where 7 | -------------------------------------------------------------------------------- /data/examples/module-header/singleline-empty-out.hs: -------------------------------------------------------------------------------- 1 | -- | This demonstrates a BUG. 2 | module Foo () where 3 | -------------------------------------------------------------------------------- /data/examples/other/comment-before-hanging-out.hs: -------------------------------------------------------------------------------- 1 | x = Just 2 | -- comment 3 | do 4 | foo 5 | bar 6 | -------------------------------------------------------------------------------- /data/examples/declaration/data/deriving-out.hs: -------------------------------------------------------------------------------- 1 | newtype R r a = R (ReaderT r IO a) 2 | deriving (MonadReader r) 3 | -------------------------------------------------------------------------------- /data/examples/declaration/data/unnamed-field-comment-1-out.hs: -------------------------------------------------------------------------------- 1 | data X 2 | = B 3 | !Int -- ^ y 4 | C 5 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/type-family/operator-out.hs: -------------------------------------------------------------------------------- 1 | type family a ! b 2 | 3 | type family a . b 4 | -------------------------------------------------------------------------------- /data/examples/declaration/type/lits-out.hs: -------------------------------------------------------------------------------- 1 | type A = "foo" 2 | 3 | type B = 4 | "foo\ 5 | \bar" 6 | -> () 7 | -------------------------------------------------------------------------------- /data/examples/declaration/type/splice-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | type Foo = $(bar [t|Int|]) 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/explicit-type-out.hs: -------------------------------------------------------------------------------- 1 | foo = 5 :: Int 2 | 3 | bar = 4 | 5 5 | :: Int 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/infix/unicode.hs: -------------------------------------------------------------------------------- 1 | main = print ('a' → 'a') 2 | where 3 | (→) = (,) 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/multiple-matches-out.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int 2 | foo 5 = 10 3 | foo _ = 12 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operators-0.hs: -------------------------------------------------------------------------------- 1 | a = 2 | b & c .~ d 3 | & e %~ f 4 | g 5 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/tricky-parens-out.hs: -------------------------------------------------------------------------------- 1 | handleStuff = 2 | (let foo = foo 3 | in foo) 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/unboxed-string-lit.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MagicHash #-} 2 | 3 | main = new "p"# 4 | -------------------------------------------------------------------------------- /data/examples/import/comments-per-import-out.hs: -------------------------------------------------------------------------------- 1 | -- (1) 2 | import Bar -- (2) 3 | import Baz -- (3) 4 | import Foo 5 | -------------------------------------------------------------------------------- /data/examples/import/merging-1.hs: -------------------------------------------------------------------------------- 1 | import "foo" Foo (foo) 2 | import "bar" Foo (bar) 3 | import "foo" Foo (baz) 4 | -------------------------------------------------------------------------------- /data/examples/module-header/multiline2-out.hs: -------------------------------------------------------------------------------- 1 | module Foo 2 | ( foo 3 | , bar 4 | , baz 5 | ) 6 | where 7 | -------------------------------------------------------------------------------- /data/examples/module-header/simple-with-comments-out.hs: -------------------------------------------------------------------------------- 1 | -- | Here we go. 2 | module Main where 3 | 4 | -- Wow. 5 | -------------------------------------------------------------------------------- /data/examples/module-header/simple-with-comments.hs: -------------------------------------------------------------------------------- 1 | -- | Here we go. 2 | 3 | module Main where 4 | 5 | -- Wow. 6 | -------------------------------------------------------------------------------- /data/examples/other/comment-multiline-after.hs: -------------------------------------------------------------------------------- 1 | foo :: Int {- ^ start index -} -> Int {- ^ length -} -> t a -> t a 2 | -------------------------------------------------------------------------------- /data/examples/other/parens-trailing-idempotence.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | quux (\x -> 3 | foo 4 | -- foo 5 | ) bar 6 | -------------------------------------------------------------------------------- /Setup.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import Distribution.Simple 4 | 5 | main :: IO () 6 | main = defaultMain 7 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do-where.hs: -------------------------------------------------------------------------------- 1 | f :: Maybe Int 2 | f = do 3 | return c 4 | where 5 | c = 0 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/equality-constraints.hs: -------------------------------------------------------------------------------- 1 | foo :: (a ~ b) => a -> b -> Int 2 | foo = undefined 3 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/infix/unicode-out.hs: -------------------------------------------------------------------------------- 1 | main = print ('a' → 'a') 2 | where 3 | (→) = (,) 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/tricky-parens.hs: -------------------------------------------------------------------------------- 1 | handleStuff = 2 | ( let foo = foo 3 | in foo 4 | ) 5 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/typed-expressions.hs: -------------------------------------------------------------------------------- 1 | foo x = x::Int 2 | bar x = Just x :: 3 | Maybe String 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/unboxed-string-lit-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MagicHash #-} 2 | 3 | main = new "p"# 4 | -------------------------------------------------------------------------------- /data/examples/module-header/warning-pragma.hs: -------------------------------------------------------------------------------- 1 | module Test {-# WARNING "This module is very internal" 2 | #-} where 3 | -------------------------------------------------------------------------------- /data/examples/declaration/type-synonyms/with-weird-haddock.hs: -------------------------------------------------------------------------------- 1 | type Elims = [Elim] -- ^ eliminations ordered left-to-right. 2 | -------------------------------------------------------------------------------- /data/examples/declaration/type/splice.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | type Foo = $( bar [t|Int|] ) 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do-where-out.hs: -------------------------------------------------------------------------------- 1 | f :: Maybe Int 2 | f = do 3 | return c 4 | where 5 | c = 0 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/equality-constraints-out.hs: -------------------------------------------------------------------------------- 1 | foo :: (a ~ b) => a -> b -> Int 2 | foo = undefined 3 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/infix/applicative-out.hs: -------------------------------------------------------------------------------- 1 | f = 2 | Foo <$> bar 3 | <*> baz 4 | <*> baz' 5 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/infix/applicative.hs: -------------------------------------------------------------------------------- 1 | f = 2 | Foo <$> bar 3 | <*> baz 4 | <*> baz' 5 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operators-0-out.hs: -------------------------------------------------------------------------------- 1 | a = 2 | b & c .~ d 3 | & e 4 | %~ f 5 | g 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operators-5-out.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | map bar $ 3 | [ baz 4 | ] 5 | ++ quux 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/strictness.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE BangPatterns #-} 2 | 3 | !a = () 4 | ~b = () 5 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/typed-hole.hs: -------------------------------------------------------------------------------- 1 | foo = 1 `_` 2 2 | 3 | bar = 1 `_a` 2 4 | 5 | baz = _ `something` _ 6 | -------------------------------------------------------------------------------- /data/diff-tests/outputs/trimming.txt: -------------------------------------------------------------------------------- 1 | TEST 2 | @@ -7,2 +7,2 @@ 3 | main :: IO () 4 | - main = return () 5 | + main = pure () 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operators-2-out.hs: -------------------------------------------------------------------------------- 1 | foo n 2 | | x || y && z || n ** x 3 | || x && n = 4 | 42 5 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operators-2.hs: -------------------------------------------------------------------------------- 1 | foo n 2 | | x || y && z || n ** x 3 | || x && n = 4 | 42 5 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/typed-hole-out.hs: -------------------------------------------------------------------------------- 1 | foo = 1 `_` 2 2 | 3 | bar = 1 `_a` 2 4 | 5 | baz = _ `something` _ 6 | -------------------------------------------------------------------------------- /data/examples/import/qualified-prelude.hs: -------------------------------------------------------------------------------- 1 | module P where 2 | 3 | import Prelude hiding (id, (.)) 4 | import qualified Prelude 5 | -------------------------------------------------------------------------------- /data/examples/module-header/warning-pragma-singleton-list-out.hs: -------------------------------------------------------------------------------- 1 | module Test {-# WARNING "There's only one line here." #-} where 2 | -------------------------------------------------------------------------------- /data/examples/other/haddock-sections.hs: -------------------------------------------------------------------------------- 1 | -- $weird #anchor# 2 | -- 3 | -- Section 1 4 | 5 | -- $normal 6 | -- 7 | -- Section 2 8 | -------------------------------------------------------------------------------- /data/examples/declaration/data/gadt-syntax-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE GADTSyntax #-} 2 | 3 | data Foo where MKFoo :: a -> (a -> Bool) -> Foo 4 | -------------------------------------------------------------------------------- /data/examples/declaration/data/gadt-syntax.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE GADTSyntax #-} 2 | 3 | data Foo where { MKFoo :: a -> (a->Bool) -> Foo } 4 | -------------------------------------------------------------------------------- /data/examples/declaration/default/default-out.hs: -------------------------------------------------------------------------------- 1 | default (Int, Foo, Bar) 2 | 3 | default 4 | ( Int 5 | , Foo 6 | , Bar 7 | ) 8 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/closed-type-family/with-equal-sign-out.hs: -------------------------------------------------------------------------------- 1 | type family TF a b = result where 2 | TF a b = Int 3 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/closed-type-family/with-equal-sign.hs: -------------------------------------------------------------------------------- 1 | type family TF a b = result where 2 | TF a b = Int 3 | -------------------------------------------------------------------------------- /data/examples/declaration/type-synonyms/with-weird-haddock-out.hs: -------------------------------------------------------------------------------- 1 | type Elims = 2 | [Elim] -- ^ eliminations ordered left-to-right. 3 | -------------------------------------------------------------------------------- /data/examples/declaration/type/forall.hs: -------------------------------------------------------------------------------- 1 | type CoerceLocalSig m m' = 2 | forall r a. 3 | LocalSig m r a -> 4 | LocalSig m' r a 5 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do/comment-spacing.hs: -------------------------------------------------------------------------------- 1 | foo = do 2 | bar 3 | -- foo 4 | baz 5 | 6 | -- foo 7 | quux 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/strictness-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE BangPatterns #-} 2 | 3 | !a = () 4 | 5 | ~b = () 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/typed-expressions-out.hs: -------------------------------------------------------------------------------- 1 | foo x = x :: Int 2 | 3 | bar x = 4 | Just x 5 | :: Maybe String 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/other/line-multi-line.hs: -------------------------------------------------------------------------------- 1 | x :: [Int] 2 | x = [ 3 | 1 4 | , 2 5 | , somethingSomething 3 6 | ] 7 | -------------------------------------------------------------------------------- /data/examples/import/qualified-prelude-out.hs: -------------------------------------------------------------------------------- 1 | module P where 2 | 3 | import Prelude hiding (id, (.)) 4 | import qualified Prelude 5 | -------------------------------------------------------------------------------- /data/examples/module-header/warning-pragma-singleton-list.hs: -------------------------------------------------------------------------------- 1 | module Test {-# WArnING ["There's only one line here."] #-} where 2 | -------------------------------------------------------------------------------- /data/examples/other/haddock-sections-out.hs: -------------------------------------------------------------------------------- 1 | -- $weird #anchor# 2 | -- 3 | -- Section 1 4 | 5 | -- $normal 6 | -- 7 | -- Section 2 8 | -------------------------------------------------------------------------------- /data/diff-tests/inputs/main-and-foo.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | main :: IO () 4 | main = return () 5 | 6 | foo :: Int 7 | foo = 5 8 | -------------------------------------------------------------------------------- /data/examples/declaration/class/empty-classes.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Foo! 4 | class Foo a where 5 | -- | Bar! 6 | class Bar a 7 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/type-family/injective.hs: -------------------------------------------------------------------------------- 1 | type family Id a = r | r -> a 2 | type family F a b c = d | d -> a c b 3 | -------------------------------------------------------------------------------- /data/examples/declaration/type/forall-out.hs: -------------------------------------------------------------------------------- 1 | type CoerceLocalSig m m' = 2 | forall r a. 3 | LocalSig m r a 4 | -> LocalSig m' r a 5 | -------------------------------------------------------------------------------- /data/examples/declaration/type/type-applications.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TypeApplications #-} 2 | 3 | type P = K @Bool @(Bool :: *) 'True 'False 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do/comment-spacing-out.hs: -------------------------------------------------------------------------------- 1 | foo = do 2 | bar 3 | -- foo 4 | baz 5 | 6 | -- foo 7 | quux 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operator-comments-2.hs: -------------------------------------------------------------------------------- 1 | x = 2 | y ++ -- commentA 3 | -- commentB 4 | f g -- commentC 5 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/as-pattern.hs: -------------------------------------------------------------------------------- 1 | main = case [1] of 2 | xs @ (x:_) -> print (x, xs) 3 | xs@[] -> print xs 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/other/line-multi-line-out.hs: -------------------------------------------------------------------------------- 1 | x :: [Int] 2 | x = 3 | [ 1 4 | , 2 5 | , somethingSomething 3 6 | ] 7 | -------------------------------------------------------------------------------- /data/examples/import/nested-explicit-imports.hs: -------------------------------------------------------------------------------- 1 | import qualified MegaModule as M ((>>>), Either, (<<<), Monad( 2 | return, (>>=), (>>))) 3 | -------------------------------------------------------------------------------- /data/examples/other/comment-multiline-after-out.hs: -------------------------------------------------------------------------------- 1 | foo 2 | :: Int -- ^ start index 3 | -> Int -- ^ length 4 | -> t a 5 | -> t a 6 | -------------------------------------------------------------------------------- /data/examples/other/consequetive-pipe-comments-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Foo. 4 | 5 | -- | Bar. 6 | bar :: Int 7 | bar = 5 8 | -------------------------------------------------------------------------------- /data/examples/other/consequetive-pipe-comments.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Foo. 4 | 5 | -- | Bar. 6 | 7 | bar :: Int 8 | bar = 5 9 | -------------------------------------------------------------------------------- /data/examples/other/pragma-no-header-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE DataKinds #-} 2 | {-# LANGUAGE LambdaCase #-} 3 | {-# LANGUAGE ViewPatterns #-} 4 | -------------------------------------------------------------------------------- /data/diff-tests/inputs/main-and-foo-v2.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | main :: IO () 4 | main = pure () 5 | 6 | foo :: Int 7 | foo = 5 8 | -------------------------------------------------------------------------------- /data/examples/declaration/class/empty-classes-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Foo! 4 | class Foo a 5 | 6 | -- | Bar! 7 | class Bar a 8 | -------------------------------------------------------------------------------- /data/examples/declaration/data/gadt/multiline-where.hs: -------------------------------------------------------------------------------- 1 | data 2 | Foo 3 | a 4 | b 5 | c where 6 | Foo :: a -> b -> c -> Foo a b c 7 | -------------------------------------------------------------------------------- /data/examples/declaration/data/newtype-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | newtype Foo = Foo Int 5 | deriving (Eq, Show) 6 | -------------------------------------------------------------------------------- /data/examples/declaration/data/newtype.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | 5 | newtype Foo = Foo Int 6 | deriving (Eq, Show) 7 | -------------------------------------------------------------------------------- /data/examples/declaration/data/with-weird-haddock.hs: -------------------------------------------------------------------------------- 1 | data PlusLevel' t = Plus Integer (LevelAtom' t) -- ^ @n + ℓ@. 2 | deriving (Show, Data) 3 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/type/unicode.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE UnicodeSyntax #-} 2 | 3 | foo ∷ ∀a. Show a ⇒ a → String 4 | foo = const () 5 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/data-family/no-annotation-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Documentation. 4 | data family Array e 5 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/data-family/no-annotation.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Documentation. 4 | 5 | data family Array e 6 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/type-family/injective-out.hs: -------------------------------------------------------------------------------- 1 | type family Id a = r | r -> a 2 | 3 | type family F a b c = d | d -> a c b 4 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/type-family/simple-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Documentation. 4 | type family Elem c :: Type 5 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/type-family/simple.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Documentation. 4 | 5 | type family Elem c :: Type 6 | -------------------------------------------------------------------------------- /data/examples/declaration/type/type-applications-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TypeApplications #-} 2 | 3 | type P = K @Bool @(Bool :: *) 'True 'False 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/blank-lines-where-out.hs: -------------------------------------------------------------------------------- 1 | foo = x + y + z 2 | where 3 | x = 10 4 | 5 | y = 11 6 | z = 12 7 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/blank-lines-where.hs: -------------------------------------------------------------------------------- 1 | foo = x + y + z 2 | where 3 | 4 | x = 10 5 | 6 | y = 11 7 | z = 12 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operators-3.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | op <> n <+> colon <+> prettySe <+> text "=" <+> 3 | prettySe <> text sc 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/as-pattern-out.hs: -------------------------------------------------------------------------------- 1 | main = case [1] of 2 | xs@(x : _) -> print (x, xs) 3 | xs@[] -> print xs 4 | -------------------------------------------------------------------------------- /data/examples/module-header/shebang-with-pragmas-out.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env stack 2 | 3 | {-# LANGUAGE OverloadedStrings #-} 4 | 5 | main = pure () 6 | -------------------------------------------------------------------------------- /data/examples/module-header/shebang-with-pragmas.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env stack 2 | 3 | {-# LANGUAGE OverloadedStrings #-} 4 | 5 | main = pure () 6 | -------------------------------------------------------------------------------- /data/examples/module-header/warning-pragma-out.hs: -------------------------------------------------------------------------------- 1 | module Test 2 | {-# WARNING 3 | "This module is very internal" 4 | #-} 5 | where 6 | -------------------------------------------------------------------------------- /data/examples/other/comment-glued-together.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | {- | Foo. -} 4 | -- Bar 5 | main :: IO () 6 | main = return () 7 | -------------------------------------------------------------------------------- /data/examples/other/following-comment-last-0.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Another datatype... 4 | data D' 5 | -- ^ ...with two docstrings. 6 | -------------------------------------------------------------------------------- /data/examples/other/multiline-comments-reindent-out.hs: -------------------------------------------------------------------------------- 1 | {- 2 | And so here we have a 3 | multiline comment. 4 | 5 | Indeed. 6 | -} 7 | -------------------------------------------------------------------------------- /data/examples/other/parens-trailing-idempotence-out.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | quux 3 | (\x -> 4 | foo 5 | -- foo 6 | ) 7 | bar 8 | -------------------------------------------------------------------------------- /data/examples/other/pragma-no-header.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE LambdaCase #-} 2 | {-# LANGuagE ViewPatterns #-} 3 | {-# language DataKinds, LambdaCase #-} 4 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/type/long-function-name-out.hs: -------------------------------------------------------------------------------- 1 | longFunctionName 2 | :: a 3 | -> b 4 | -> c 5 | -> d 6 | -> (a, b, c, d) 7 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/type/long-function-name.hs: -------------------------------------------------------------------------------- 1 | longFunctionName 2 | :: a 3 | -> b 4 | -> c 5 | -> d 6 | -> (a, b, c, d) 7 | -------------------------------------------------------------------------------- /data/examples/declaration/splice/typed-splice-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | x = 4 | $$( foo bar 5 | ) 6 | 7 | x = $$foo 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/blank-lines-let-out.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | let x = 10 3 | 4 | y = 11 5 | z = 12 6 | in x + y + z 7 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/multiline-arguments.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int -> Int -> Int 2 | foo (Foo g o) 3 | (Bar 4 | x y) z = x 5 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/negation-out.hs: -------------------------------------------------------------------------------- 1 | foo :: Int 2 | foo = (-2) 3 | 4 | bar :: Int 5 | bar = -2 6 | 7 | baz :: Int 8 | baz = - 2 9 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/negation.hs: -------------------------------------------------------------------------------- 1 | foo :: Int 2 | foo = (-2) 3 | 4 | bar :: Int 5 | bar = -2 6 | 7 | baz :: Int 8 | baz = - 2 9 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operator-comments-2-out.hs: -------------------------------------------------------------------------------- 1 | x = 2 | y 3 | ++ f g -- commentA 4 | -- commentB 5 | -- commentC 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operators-3-out.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | op <> n <+> colon <+> prettySe <+> text "=" 3 | <+> prettySe <> text sc 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/overloaded-labels.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedLabels #-} 2 | 3 | foo = #field 4 | bar = (#this ) ( #that) 5 | -------------------------------------------------------------------------------- /data/examples/import/comments-inside-imports-out.hs: -------------------------------------------------------------------------------- 1 | -- x 2 | 3 | import qualified -- x 4 | Bar 5 | import qualified -- x 6 | Baz 7 | import Foo 8 | -------------------------------------------------------------------------------- /data/examples/module-header/shebang.hs: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env runhaskell 2 | 3 | import Prelude 4 | 5 | main :: IO () 6 | main = putStrLn "hello world" 7 | -------------------------------------------------------------------------------- /data/examples/module-header/stack-header-0.hs: -------------------------------------------------------------------------------- 1 | -- stack runhaskell 2 | {-# LANGUAGE OverloadedStrings #-} 3 | main = return () 4 | -- stack runhaskell 5 | -------------------------------------------------------------------------------- /data/examples/other/comment-glued-together-out.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | -- | Foo. 4 | 5 | -- Bar 6 | main :: IO () 7 | main = return () 8 | -------------------------------------------------------------------------------- /data/examples/other/following-comment-last-0-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Another datatype... 4 | data D' 5 | -- ^ ...with two docstrings. 6 | -------------------------------------------------------------------------------- /data/examples/declaration/class/newlines-after-where-out.hs: -------------------------------------------------------------------------------- 1 | class Num a where 2 | (+) :: a -> a -> a 3 | 4 | class Num a where 5 | (+) :: a -> a -> a 6 | -------------------------------------------------------------------------------- /data/examples/declaration/data/gadt/multiline-where-out.hs: -------------------------------------------------------------------------------- 1 | data 2 | Foo 3 | a 4 | b 5 | c 6 | where 7 | Foo :: a -> b -> c -> Foo a b c 8 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/type/unicode-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE UnicodeSyntax #-} 2 | 3 | foo :: forall a. Show a => a -> String 4 | foo = const () 5 | -------------------------------------------------------------------------------- /data/examples/declaration/splice/typed-splice.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | x = $$( foo bar 4 | ) 5 | 6 | x = $$foo 7 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/data-family/simple-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Documentation. 4 | data family GMap k :: Type -> Type 5 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/data-family/simple.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Documentation. 4 | 5 | data family GMap k :: Type -> Type 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/infix/comments.hs: -------------------------------------------------------------------------------- 1 | main = 2 | bar $ -- bar 3 | baz -- baz 4 | 5 | bar $ 6 | {- foo 7 | -} 8 | bar 9 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operators-4-out.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | line <> bindingOf <+> text "=" <+> tPretty <+> colon 3 | <+> align <> prettyPs 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operators-4.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | line <> bindingOf <+> text "=" <+> tPretty <+> colon <+> 3 | align <> prettyPs 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/overloaded-labels-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedLabels #-} 2 | 3 | foo = #field 4 | 5 | bar = (#this) (#that) 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/sig-pattern-out.hs: -------------------------------------------------------------------------------- 1 | f = do 2 | x :: a <- g 3 | 4 | f = do 5 | (x, y) 6 | :: (a, b) <- 7 | g 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/sig-pattern.hs: -------------------------------------------------------------------------------- 1 | f = do 2 | x :: a <- g 3 | 4 | f = do 5 | (x, y) 6 | :: (a, b) 7 | <- g 8 | -------------------------------------------------------------------------------- /data/examples/import/merging-2.hs: -------------------------------------------------------------------------------- 1 | import qualified Foo (foo1) 2 | import Foo hiding (foo2) 3 | import qualified Foo (bar3) 4 | import Foo hiding (bar4) 5 | -------------------------------------------------------------------------------- /data/examples/module-header/shebang-out.hs: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env runhaskell 2 | 3 | import Prelude 4 | 5 | main :: IO () 6 | main = putStrLn "hello world" 7 | -------------------------------------------------------------------------------- /data/examples/other/comment-following-preceding-gap.hs: -------------------------------------------------------------------------------- 1 | foo = bar 2 | where 3 | baz = return (quux) -- Foo 4 | 5 | -- Bar 6 | meme = gege 7 | -------------------------------------------------------------------------------- /data/examples/declaration/data/unnamed-field-comment-0-out.hs: -------------------------------------------------------------------------------- 1 | data Foo 2 | = -- | Bar 3 | Bar 4 | Field1 -- ^ Field 1 5 | Field2 -- ^ Field 2 6 | -------------------------------------------------------------------------------- /data/examples/declaration/data/unnamed-field-comment-0.hs: -------------------------------------------------------------------------------- 1 | data Foo 2 | = -- | Bar 3 | Bar 4 | Field1 -- ^ Field 1 5 | Field2 -- ^ Field 2 6 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/newlines-after-where-out.hs: -------------------------------------------------------------------------------- 1 | instance Num X where 2 | (+) = undefined 3 | 4 | instance Num Y where 5 | (+) = undefined 6 | -------------------------------------------------------------------------------- /data/examples/declaration/splice/grouped-splices-out.hs: -------------------------------------------------------------------------------- 1 | $(deriveJSON fieldLabelMod ''A) 2 | $(deriveJSON fieldLabelMod ''B) 3 | $(deriveJSON fieldLabelMod ''C) 4 | -------------------------------------------------------------------------------- /data/examples/declaration/splice/grouped-splices.hs: -------------------------------------------------------------------------------- 1 | $(deriveJSON fieldLabelMod ''A) 2 | $(deriveJSON fieldLabelMod ''B) 3 | $(deriveJSON fieldLabelMod ''C) 4 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/type-family/no-annotation-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Documentation. 4 | type family F a b :: Type -> Type 5 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/type-family/no-annotation.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Documentation. 4 | 5 | type family F a b :: Type -> Type 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/infix/comments-out.hs: -------------------------------------------------------------------------------- 1 | main = 2 | bar $ -- bar 3 | baz -- baz 4 | 5 | bar $ 6 | {- foo 7 | -} 8 | bar 9 | -------------------------------------------------------------------------------- /data/examples/import/explicit-imports-with-comments.hs: -------------------------------------------------------------------------------- 1 | import qualified MegaModule as M 2 | ( (>>>) -- (1) 3 | , (<<<) -- (2) 4 | , Either -- (3) 5 | ) 6 | -------------------------------------------------------------------------------- /data/examples/other/comment-following-preceding-gap-out.hs: -------------------------------------------------------------------------------- 1 | foo = bar 2 | where 3 | baz = return (quux) -- Foo 4 | 5 | -- Bar 6 | meme = gege 7 | -------------------------------------------------------------------------------- /data/examples/declaration/class/newlines-after-where.hs: -------------------------------------------------------------------------------- 1 | class Num a where 2 | (+) :: a -> a -> a 3 | 4 | class Num a where 5 | 6 | 7 | (+) :: a -> a -> a 8 | -------------------------------------------------------------------------------- /data/examples/declaration/data/simple-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | And here we have 'Foo'. 4 | data Foo = Foo | Bar Int | Baz 5 | deriving (Eq, Show) 6 | -------------------------------------------------------------------------------- /data/examples/declaration/data/simple.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | And here we have 'Foo'. 4 | 5 | data Foo = Foo | Bar Int | Baz 6 | deriving (Eq, Show) 7 | -------------------------------------------------------------------------------- /data/examples/declaration/data/with-weird-haddock-out.hs: -------------------------------------------------------------------------------- 1 | data PlusLevel' t 2 | = -- | @n + ℓ@. 3 | Plus Integer (LevelAtom' t) 4 | deriving (Show, Data) 5 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/newlines-after-where.hs: -------------------------------------------------------------------------------- 1 | instance Num X where 2 | (+) = undefined 3 | 4 | instance Num Y where 5 | 6 | 7 | (+) = undefined 8 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/type/context-single-line.hs: -------------------------------------------------------------------------------- 1 | functionName 2 | :: (C1, C2, C3) 3 | => a 4 | -> b 5 | -> c 6 | -> d 7 | -> (a, b, c, d) 8 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/closed-type-family/no-annotation-out.hs: -------------------------------------------------------------------------------- 1 | type family F a where 2 | F Int = Double 3 | F Bool = Char 4 | F a = String 5 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/closed-type-family/no-annotation.hs: -------------------------------------------------------------------------------- 1 | type family F a where 2 | F Int = Double 3 | F Bool = Char 4 | F a = String 5 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/blank-lines-let.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | let 3 | 4 | x = 10 5 | 6 | y = 11 7 | z = 12 8 | 9 | in x + y + z 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/unboxed-tuples.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE UnboxedTuples #-} 2 | 3 | foo = (# 1,2,3 #) 4 | bar = (# 5 | 1, 6 | 2, 7 | 3 #) 8 | -------------------------------------------------------------------------------- /data/examples/module-header/warning-pragma-multiline.hs: -------------------------------------------------------------------------------- 1 | module Test {-# DEPRECATED "This module is unstable" #-} 2 | (foo, bar, baz) where 3 | 4 | import Blah 5 | -------------------------------------------------------------------------------- /data/diff-tests/outputs/no-following.txt: -------------------------------------------------------------------------------- 1 | TEST 2 | @@ -1,4 +1,4 @@ 3 | module Main (main) where 4 | 5 | main :: IO () 6 | - main = return () 7 | + main = pure () 8 | -------------------------------------------------------------------------------- /data/examples/declaration/default/default.hs: -------------------------------------------------------------------------------- 1 | default ( Int , Foo , Bar ) 2 | 3 | default ( Int 4 | , Foo, 5 | Bar 6 | ) 7 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/type/context-single-line-out.hs: -------------------------------------------------------------------------------- 1 | functionName 2 | :: (C1, C2, C3) 3 | => a 4 | -> b 5 | -> c 6 | -> d 7 | -> (a, b, c, d) 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/list-notation-0.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | testCase "Foo" testFoo : 3 | testCase "Bar" testBar : 4 | testCase "Baz" testBaz : 5 | [] 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/tuple-sections-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TupleSections #-} 2 | 3 | foo = (,2) 4 | 5 | bar = (,5,) 6 | 7 | baz = 8 | (,,5,6,7,,,) 9 | -------------------------------------------------------------------------------- /data/examples/declaration/warning/warning-multiline.hs: -------------------------------------------------------------------------------- 1 | {-# WArNING test, 2 | foo ["These are bad functions", "Really bad!"] #-} 3 | test :: IO () 4 | test = pure () 5 | -------------------------------------------------------------------------------- /data/examples/import/comments-inside-imports.hs: -------------------------------------------------------------------------------- 1 | import -- x 2 | Foo 3 | 4 | import -- x 5 | qualified Bar 6 | 7 | import qualified 8 | -- x 9 | Baz 10 | -------------------------------------------------------------------------------- /data/examples/module-header/stack-header-0-out.hs: -------------------------------------------------------------------------------- 1 | -- stack runhaskell 2 | 3 | {-# LANGUAGE OverloadedStrings #-} 4 | 5 | main = return () 6 | 7 | -- stack runhaskell 8 | -------------------------------------------------------------------------------- /data/examples/other/comment-alignment-out.hs: -------------------------------------------------------------------------------- 1 | class Foo a where 2 | -- | Foo. 3 | foo 4 | :: Int 5 | -> a -- ^ Something 6 | 7 | -- | Bar. 8 | bar :: a 9 | -------------------------------------------------------------------------------- /data/diff-tests/outputs/no-preceding.txt: -------------------------------------------------------------------------------- 1 | TEST 2 | @@ -1,4 +1,4 @@ 3 | - module Main (foo) where 4 | + module Main (main) where 5 | 6 | main :: IO () 7 | main = return () 8 | -------------------------------------------------------------------------------- /data/examples/declaration/data/record-singleline-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | data Foo = Foo {fooX :: Int, fooY :: Int} 5 | deriving (Eq, Show) 6 | -------------------------------------------------------------------------------- /data/examples/declaration/data/record-singleline.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | 5 | data Foo = Foo { fooX :: Int , fooY :: Int } 6 | deriving (Eq, Show) 7 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/inline/conlike-out.hs: -------------------------------------------------------------------------------- 1 | foo :: Int 2 | foo = 5 3 | {-# INLINE CONLIKE foo #-} 4 | 5 | bar :: Int 6 | bar = 6 7 | {-# INLINE CONLIKE bar #-} 8 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/inline/conlike.hs: -------------------------------------------------------------------------------- 1 | foo :: Int 2 | foo = 5 3 | {-# INLINE CONLIKE foo #-} 4 | 5 | bar :: Int 6 | bar = 6 7 | {-# INLINE CONLIKE bar #-} 8 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/closed-type-family/with-forall.hs: -------------------------------------------------------------------------------- 1 | type family G a b where 2 | forall x y. G [x] (Proxy y) = Double 3 | forall z. z `G` z = Bool 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/list-notation-0-out.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | testCase "Foo" testFoo : 3 | testCase "Bar" testBar : 4 | testCase "Baz" testBaz : 5 | [] 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/tuple-sections.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TupleSections #-} 2 | 3 | foo = (,2) 4 | bar = (,5,) 5 | baz = ( 6 | ,,5,6, 7 | 7,,, 8 | ) 9 | -------------------------------------------------------------------------------- /data/examples/module-header/stack-header-1.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env stack 2 | -- stack runhaskell 3 | {-# LANGUAGE OverloadedStrings #-} 4 | main = return () 5 | -- stack runhaskell 6 | -------------------------------------------------------------------------------- /data/examples/other/comment-trailing-space-out.hs: -------------------------------------------------------------------------------- 1 | data T 2 | = {- 3 | 4 | some multi-line comment 5 | 6 | with empty lines 7 | 8 | -} 9 | A 10 | -------------------------------------------------------------------------------- /data/examples/other/comment-trailing-space.hs: -------------------------------------------------------------------------------- 1 | data T 2 | = {- 3 | 4 | some multi-line comment 5 | 6 | with empty lines 7 | 8 | -} 9 | A 10 | -------------------------------------------------------------------------------- /data/examples/other/following-comment-last-3.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Another datatype... 4 | data D' 5 | -- ^ ...with two docstrings. 6 | -- even on second line 7 | -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? (import ./nix/nixpkgs { inherit system; }) 2 | , system ? builtins.currentSystem 3 | }: 4 | 5 | (import ./default.nix { inherit pkgs; }).dev.ormoluShell 6 | -------------------------------------------------------------------------------- /data/examples/declaration/data/gadt/strictness.hs: -------------------------------------------------------------------------------- 1 | data Foo a where 2 | Foo1 :: !Int -> {-# UNPACK #-} !Bool -> Foo Int 3 | Foo2 :: {-# UNPACK #-} Maybe Int && Bool -> Foo Int 4 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/closed-type-family/with-forall-out.hs: -------------------------------------------------------------------------------- 1 | type family G a b where 2 | forall x y. G [x] (Proxy y) = Double 3 | forall z. z `G` z = Bool 4 | -------------------------------------------------------------------------------- /data/examples/declaration/type/misc-kind-signatures-out.hs: -------------------------------------------------------------------------------- 1 | instance DemoteNodeTypes ('[] :: [NodeType]) where 2 | demoteNodeTypes _ = [] 3 | 4 | b :: (Bool :: *) 5 | b = True 6 | -------------------------------------------------------------------------------- /data/examples/declaration/type/misc-kind-signatures.hs: -------------------------------------------------------------------------------- 1 | instance DemoteNodeTypes ('[] :: [NodeType]) where 2 | demoteNodeTypes _ = [] 3 | 4 | b :: (Bool :: *) 5 | b = True 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/arrow/multiline-case.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Arrows #-} 2 | 3 | f = proc x -> do 4 | x 5 | <- case x of X -> x 6 | -< y 7 | a -< b 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/strings.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MagicHash #-} 2 | 3 | foo = "foobar" 4 | bar = "foo\&bar\ \baz" 5 | baz = "foo\ 6 | \bar\ 7 | \baz" 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/unboxed-sums.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE UnboxedSums #-} 2 | 3 | foo = (# 1 | #) 4 | bar = (# | |2| #) 5 | baz = (# | 6 | | | 10 | | | | 7 | | #) 8 | -------------------------------------------------------------------------------- /data/examples/import/explicit-imports-with-comments-out.hs: -------------------------------------------------------------------------------- 1 | import qualified MegaModule as M 2 | ( -- (1) 3 | -- (2) 4 | Either -- (3) 5 | , (<<<) 6 | , (>>>) 7 | ) 8 | -------------------------------------------------------------------------------- /data/examples/module-header/warning-pragma-multiline-out.hs: -------------------------------------------------------------------------------- 1 | module Test 2 | {-# DEPRECATED "This module is unstable" #-} 3 | (foo, bar, baz) 4 | where 5 | 6 | import Blah 7 | -------------------------------------------------------------------------------- /data/examples/other/following-comment-last-3-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Another datatype... 4 | data D' 5 | -- ^ ...with two docstrings. 6 | -- even on second line 7 | -------------------------------------------------------------------------------- /data/examples/declaration/class/poly-kinded-classes.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE PolyKinds #-} 2 | 3 | class Foo (a::k) 4 | 5 | class Bar 6 | (a -- Variable 7 | :: * -- Star 8 | ) 9 | -------------------------------------------------------------------------------- /data/examples/declaration/data/gadt/strictness-out.hs: -------------------------------------------------------------------------------- 1 | data Foo a where 2 | Foo1 :: !Int -> {-# UNPACK #-} !Bool -> Foo Int 3 | Foo2 :: {-# UNPACK #-} Maybe Int && Bool -> Foo Int 4 | -------------------------------------------------------------------------------- /data/examples/declaration/data/partly-documented.hs: -------------------------------------------------------------------------------- 1 | data Optimisation = PETransform | GeneralisedNatHack -- ^ partial eval and associated transforms 2 | deriving (Show, Eq, Generic) 3 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/if-single-line.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int 2 | foo x = if x > 5 then 10 else 12 3 | 4 | bar :: Int -> Int 5 | bar x = 6 | if x > 5 then 10 else 12 7 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/multiline-arguments-out.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int -> Int -> Int 2 | foo 3 | (Foo g o) 4 | ( Bar 5 | x 6 | y 7 | ) 8 | z = x 9 | -------------------------------------------------------------------------------- /data/examples/import/misc-out.hs: -------------------------------------------------------------------------------- 1 | import A hiding 2 | ( foobarbazqux 3 | ) 4 | import {-# SOURCE #-} safe qualified Module as M hiding (a, b, c, d, e, f) 5 | import Name hiding () 6 | -------------------------------------------------------------------------------- /data/examples/other/cpp/continuation.hs: -------------------------------------------------------------------------------- 1 | foo :: Int 2 | foo = 5 3 | 4 | #define message_for(a, b) \ 5 | printf(#a " and " #b ": We love you!\n") 6 | 7 | bar :: Int 8 | bar = 6 9 | -------------------------------------------------------------------------------- /data/examples/other/following-comment-last-1.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Another datatype... 4 | data D' 5 | deriving (Show) 6 | -- ^ ...with two docstrings. 7 | 8 | -- more 9 | -------------------------------------------------------------------------------- /data/examples/other/multiple-blank-line-comment.hs: -------------------------------------------------------------------------------- 1 | module A where 2 | 3 | a = 4 | b 5 | [ f 6 | {-, 7 | 8 | 9 | -} 10 | ] 11 | -------------------------------------------------------------------------------- /data/diff-tests/inputs/main-and-bar.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | main :: IO () 4 | main = return () 5 | 6 | foo :: Int 7 | foo = 8 | 5 9 | 10 | bar :: Int 11 | bar = 6 12 | -------------------------------------------------------------------------------- /data/examples/declaration/data/existential.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ExistentialQuantification #-} 2 | 3 | data Foo = forall a. MkFoo a (a -> Bool) 4 | 5 | data Bar = forall a b. a + b => Bar a b 6 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/pattern/single-line.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE PatternSynonyms #-} 2 | 3 | pattern Arrow :: Type -> Type -> Type 4 | 5 | pattern Foo, Bar :: Type -> Type -> Type 6 | -------------------------------------------------------------------------------- /data/examples/declaration/type/visible-forall.hs: -------------------------------------------------------------------------------- 1 | -- source: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0081-forall-arrow.rst 2 | data T :: forall k -> k -> Type 3 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/if-single-line-out.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int 2 | foo x = if x > 5 then 10 else 12 3 | 4 | bar :: Int -> Int 5 | bar x = 6 | if x > 5 then 10 else 12 7 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/record/hanging-after-equal-con.hs: -------------------------------------------------------------------------------- 1 | foo = Foo 2 | { foo = 3 | -- Blah blah 4 | case x of 5 | Blah -> 1 6 | Blim -> 2 7 | } 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/record/hanging-after-equal-update.hs: -------------------------------------------------------------------------------- 1 | foo = foo 2 | { foo = 3 | -- Blah blah 4 | case x of 5 | Blah -> 1 6 | Blim -> 2 7 | } 8 | -------------------------------------------------------------------------------- /data/examples/module-header/preceding-comment-with-haddock.hs: -------------------------------------------------------------------------------- 1 | {- 2 | Here we go. 3 | -} 4 | 5 | -- | This is the module's Haddock. 6 | module Main (main) where 7 | 8 | main = return () 9 | -------------------------------------------------------------------------------- /data/examples/other/cpp/continuation-out.hs: -------------------------------------------------------------------------------- 1 | foo :: Int 2 | foo = 5 3 | 4 | #define message_for(a, b) \ 5 | printf(#a " and " #b ": We love you!\n") 6 | 7 | bar :: Int 8 | bar = 6 9 | -------------------------------------------------------------------------------- /data/examples/other/following-comment-last-1-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Another datatype... 4 | data D' 5 | deriving (Show) 6 | -- ^ ...with two docstrings. 7 | 8 | -- more 9 | -------------------------------------------------------------------------------- /data/examples/other/multiple-blank-line-comment-out.hs: -------------------------------------------------------------------------------- 1 | module A where 2 | 3 | a = 4 | b 5 | [ f 6 | {-, 7 | 8 | -} 9 | ] 10 | -------------------------------------------------------------------------------- /data/examples/other/trailing-whitespace-out.hs: -------------------------------------------------------------------------------- 1 | -- Here is a comment with trailing whitespace. 2 | foo = 5 3 | 4 | {- Block comment with trailing whitespace. 5 | Bo. 6 | -} 7 | bar = 6 8 | -------------------------------------------------------------------------------- /expected-failures/pipes.txt: -------------------------------------------------------------------------------- 1 | src/Pipes/Core.hs 2 | AST of input and AST of formatted code differ. 3 | at src/Pipes/Core.hs:(128,1)-(151,2) 4 | Please, consider reporting the bug. 5 | -------------------------------------------------------------------------------- /data/diff-tests/inputs/main-and-bar-v2.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | main :: IO () 4 | main = pure () 5 | 6 | foo :: Int 7 | foo = 8 | 5 9 | 10 | bar :: Int 11 | bar = 7 12 | -------------------------------------------------------------------------------- /data/examples/declaration/data/existential-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ExistentialQuantification #-} 2 | 3 | data Foo = forall a. MkFoo a (a -> Bool) 4 | 5 | data Bar = forall a b. a + b => Bar a b 6 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/pattern/single-line-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE PatternSynonyms #-} 2 | 3 | pattern Arrow :: Type -> Type -> Type 4 | 5 | pattern Foo, Bar :: Type -> Type -> Type 6 | -------------------------------------------------------------------------------- /data/examples/declaration/splice/untyped-splice-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | x = $(foo bar) 4 | 5 | x = 6 | $( foo 7 | bar 8 | ) 9 | 10 | x = $foo 11 | -------------------------------------------------------------------------------- /data/examples/declaration/splice/untyped-splice.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | x = $( foo bar ) 3 | 4 | x = $( 5 | foo 6 | bar ) 7 | 8 | x = $foo 9 | -------------------------------------------------------------------------------- /data/examples/declaration/type/visible-forall-out.hs: -------------------------------------------------------------------------------- 1 | -- source: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0081-forall-arrow.rst 2 | data T :: forall k -> k -> Type 3 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/application-0.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | f1 3 | p1 4 | p2 p3 5 | 6 | foo' = f2 p1 7 | p2 8 | p3 9 | 10 | foo'' = 11 | f3 p1 p2 12 | p3 13 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/arrow/multiline-case-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Arrows #-} 2 | 3 | f = proc x -> do 4 | x <- 5 | case x of X -> x 6 | -< 7 | y 8 | a -< b 9 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/backticks-lhs-out.hs: -------------------------------------------------------------------------------- 1 | x `op1` (Just 0) = True 2 | op1 x (Just _) = False 3 | op1 x Nothing = undefined 4 | 5 | op2 1 y = False 6 | x `op2` y = 7 | True 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/parallel-comprehensions-single-line.hs: -------------------------------------------------------------------------------- 1 | foo x y = [(a,b) | a<-x | b<-y] 2 | 3 | bar x y z w = [(a,b,c,d) | a<-x, b<-y, a`mod`b == 0|c<-z|d<-w ] 4 | 5 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/record/inter-comments.hs: -------------------------------------------------------------------------------- 1 | x = Just 2 | -- comment 3 | A 4 | { x 5 | } 6 | 7 | x = Just 8 | -- comment 9 | a 10 | { x 11 | } 12 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/record/updaters.hs: -------------------------------------------------------------------------------- 1 | foo x = x { a = 3 } 2 | bar x = x { 3 | abc = foo, 4 | def = Foo {a = 10} 5 | } 6 | baz x = x{ } 7 | sym x = x { (+) = 4 } 8 | -------------------------------------------------------------------------------- /data/examples/module-header/preceding-comment-with-haddock-out.hs: -------------------------------------------------------------------------------- 1 | {- 2 | Here we go. 3 | -} 4 | 5 | -- | This is the module's Haddock. 6 | module Main (main) where 7 | 8 | main = return () 9 | -------------------------------------------------------------------------------- /data/examples/module-header/stack-header-1-out.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env stack 2 | -- stack runhaskell 3 | 4 | {-# LANGUAGE OverloadedStrings #-} 5 | 6 | main = return () 7 | 8 | -- stack runhaskell 9 | -------------------------------------------------------------------------------- /data/examples/other/comment-alignment.hs: -------------------------------------------------------------------------------- 1 | class Foo a where 2 | 3 | -- | Foo. 4 | 5 | foo 6 | :: Int 7 | -> a -- ^ Something 8 | 9 | -- | Bar. 10 | 11 | bar :: a 12 | -------------------------------------------------------------------------------- /data/examples/other/comment-two-blocks-out.hs: -------------------------------------------------------------------------------- 1 | newNames :: [(String, String)] 2 | newNames = 3 | let (*) = flip (,) 4 | in [ "Control" * "Monad" 5 | -- Foo 6 | 7 | -- Bar 8 | ] 9 | -------------------------------------------------------------------------------- /data/diff-tests/inputs/spaced-v2.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | 4 | 5 | 6 | 7 | main :: IO () 8 | main = pure () 9 | 10 | 11 | 12 | 13 | 14 | 15 | foo :: Int 16 | foo = 5 17 | -------------------------------------------------------------------------------- /data/diff-tests/inputs/spaced.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | 4 | 5 | 6 | 7 | main :: IO () 8 | main = return () 9 | 10 | 11 | 12 | 13 | 14 | 15 | foo :: Int 16 | foo = 5 17 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/multi-parameter-out.hs: -------------------------------------------------------------------------------- 1 | instance MonadReader a ((->) a) where ask = id 2 | 3 | instance MonadState s (State s) where 4 | get = State.get 5 | put = State.put 6 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/type/infix-promoted-type-constructor-out.hs: -------------------------------------------------------------------------------- 1 | fun1 :: Def ('[Ref s (Stored Uint32), IBool] 'T.:-> IBool) 2 | fun2 :: Def ('[Ref s (Stored Uint32), IBool] ':-> IBool) 3 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/type/infix-promoted-type-constructor.hs: -------------------------------------------------------------------------------- 1 | fun1 :: Def ('[ Ref s (Stored Uint32), IBool] 'T.:-> IBool) 2 | fun2 :: Def ('[ Ref s (Stored Uint32), IBool] ':-> IBool) 3 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/strings-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MagicHash #-} 2 | 3 | foo = "foobar" 4 | 5 | bar = "foo\&barbaz" 6 | 7 | baz = 8 | "foo\ 9 | \bar\ 10 | \baz" 11 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/type-applications-and-splice-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | {-# LANGUAGE TypeApplications #-} 3 | 4 | staticKey name = [|sing @ $(symFQN name)|] 5 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/type-applications-and-splice.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | {-# LANGUAGE TypeApplications #-} 3 | 4 | staticKey name = [| sing @ $(symFQN name) |] 5 | -------------------------------------------------------------------------------- /data/examples/import/simple-out.hs: -------------------------------------------------------------------------------- 1 | import Data.Text 2 | import Data.Text (a, b, c) 3 | import Data.Text hiding (a, b, c) 4 | import qualified Data.Text (a, b, c) 5 | import qualified Data.Text as T 6 | -------------------------------------------------------------------------------- /data/examples/other/trailing-whitespace.hs: -------------------------------------------------------------------------------- 1 | -- Here is a comment with trailing whitespace. 2 | foo = 5 3 | 4 | {- Block comment with trailing whitespace. 5 | Bo. 6 | -} 7 | bar = 6 8 | -------------------------------------------------------------------------------- /data/diff-tests/inputs/main-and-baz-v2.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | main :: IO () 4 | main = pure () 5 | 6 | foo :: Int 7 | foo = 8 | 5 9 | + 5 10 | 11 | bar :: Int 12 | bar = 7 13 | -------------------------------------------------------------------------------- /data/diff-tests/inputs/main-and-baz.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | main :: IO () 4 | main = return () 5 | 6 | foo :: Int 7 | foo = 8 | 5 9 | + 5 10 | 11 | bar :: Int 12 | bar = 6 13 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/multi-parameter.hs: -------------------------------------------------------------------------------- 1 | instance MonadReader a ((->) a) where ask = id 2 | 3 | instance MonadState s (State s) 4 | where 5 | get = State.get 6 | put = State.put 7 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do/recursive-do-mdo.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE RecursiveDo #-} 2 | 3 | baz = 4 | mdo bar a 5 | a <- foo 6 | b <- bar 7 | 1 2 3 8 | return (a + b) 9 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/if-with-comment-out.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | if undefined 3 | then -- then comment 4 | undefined 5 | else -- else comment 6 | 7 | do 8 | undefined 9 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/if-with-comment.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | if undefined 3 | -- then comment 4 | then undefined 5 | -- else comment 6 | else 7 | do 8 | undefined 9 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/unboxed-tuples-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE UnboxedTuples #-} 2 | 3 | foo = (# 1, 2, 3 #) 4 | 5 | bar = 6 | (# 7 | 1 8 | , 2 9 | , 3 10 | #) 11 | -------------------------------------------------------------------------------- /data/examples/import/explicit-imports.hs: -------------------------------------------------------------------------------- 1 | import qualified MegaModule as M 2 | ((>>>), MonadBaseControl, void, MaybeT(..), join, Maybe(Nothing, Just), liftIO, Either, (<<<), Monad(return, (>>=), (>>))) 3 | -------------------------------------------------------------------------------- /data/examples/other/comment-after-preceding-haddock.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | A 4 | 5 | -- B 6 | 7 | type D = E 8 | 9 | -- | This is 'f' 10 | 11 | -- * Comment 12 | f :: a -> b 13 | -------------------------------------------------------------------------------- /data/examples/other/comment-two-blocks.hs: -------------------------------------------------------------------------------- 1 | newNames :: [(String, String)] 2 | newNames = let (*) = flip (,) in 3 | ["Control" * "Monad" 4 | 5 | -- Foo 6 | 7 | -- Bar 8 | 9 | ] 10 | -------------------------------------------------------------------------------- /data/examples/other/cpp/separation-0a.hs: -------------------------------------------------------------------------------- 1 | instance Stream s => Monad (ParsecT e s m) where 2 | return = pure 3 | (>>=) = pBind 4 | #if !(MIN_VERSION_base(4,13,0)) 5 | fail = Fail.fail 6 | #endif 7 | -------------------------------------------------------------------------------- /data/examples/declaration/class/poly-kinded-classes-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE PolyKinds #-} 2 | 3 | class Foo (a :: k) 4 | 5 | class 6 | Bar 7 | ( a -- Variable 8 | :: * -- Star 9 | ) 10 | -------------------------------------------------------------------------------- /data/examples/declaration/data/partly-documented-out.hs: -------------------------------------------------------------------------------- 1 | data Optimisation 2 | = PETransform 3 | | -- | partial eval and associated transforms 4 | GeneralisedNatHack 5 | deriving (Show, Eq, Generic) 6 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/complete/complete-out.hs: -------------------------------------------------------------------------------- 1 | {-# COMPLETE A, B, C :: Foo #-} 2 | 3 | {-# COMPLETE A, B #-} 4 | 5 | {-# COMPLETE 6 | A 7 | , B 8 | , C 9 | :: Foo 10 | #-} 11 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/type/context-multi-line-out.hs: -------------------------------------------------------------------------------- 1 | functionName 2 | :: ( C1 3 | , C2 4 | , C3 5 | ) 6 | => a 7 | -> b 8 | -> c 9 | -> d 10 | -> (a, b, c, d) 11 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/type/context-multi-line.hs: -------------------------------------------------------------------------------- 1 | functionName 2 | :: ( C1 3 | , C2 4 | , C3 5 | ) 6 | => a 7 | -> b 8 | -> c 9 | -> d 10 | -> (a, b, c, d) 11 | -------------------------------------------------------------------------------- /data/examples/declaration/splice/quasiquote.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE QuasiQuotes #-} 2 | 3 | x = [foo| foo bar |] 4 | 5 | x = [e| foo 6 | bar {- -} 7 | |] 8 | 9 | [d| foo bar 10 | 11 | |] 12 | -------------------------------------------------------------------------------- /data/examples/declaration/type-synonyms/simple-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Documentation. 4 | type Foo a b c = Bar c a b 5 | 6 | type a ~> b = TyFun a b -> Type 7 | 8 | type (a :+: b) c d e = () 9 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do/expr.hs: -------------------------------------------------------------------------------- 1 | quux = something $ do 2 | foo 3 | case x of 4 | 1 -> 10 5 | 2 -> 20 6 | bar 7 | if something 8 | then x 9 | else y 10 | baz 11 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/parallel-comprehensions-single-line-out.hs: -------------------------------------------------------------------------------- 1 | foo x y = [(a, b) | a <- x | b <- y] 2 | 3 | bar x y z w = [(a, b, c, d) | a <- x, b <- y, a `mod` b == 0 | c <- z | d <- w] 4 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/splice-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | bar = $bar 4 | 5 | bar' = $(bar "something") 6 | 7 | baz = $$baz 8 | 9 | baz' = $$(baz "something") 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/splice.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | bar = $bar 4 | 5 | bar' = $(bar "something") 6 | 7 | baz = $$baz 8 | 9 | baz' = $$(baz "something") 10 | -------------------------------------------------------------------------------- /data/examples/import/qualified-post-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ImportQualifiedPost #-} 2 | 3 | import Data.Text qualified (a, b, c) 4 | import Data.Text qualified hiding (a, b, c) 5 | import Data.Text qualified as T 6 | -------------------------------------------------------------------------------- /data/examples/import/qualified-post.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ImportQualifiedPost #-} 2 | 3 | import qualified Data.Text as T 4 | import qualified Data.Text (a, c, b) 5 | import Data.Text qualified hiding (c, b, a) 6 | -------------------------------------------------------------------------------- /data/examples/other/comment-after-preceding-haddock-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | A 4 | 5 | -- B 6 | 7 | type D = E 8 | 9 | -- | This is 'f' 10 | 11 | -- * Comment 12 | f :: a -> b 13 | -------------------------------------------------------------------------------- /data/examples/other/cpp/separation-2a.hs: -------------------------------------------------------------------------------- 1 | ffff, ffffffff :: Natural 2 | #ifdef HASKELL_ZIP_DEV_MODE 3 | ffff = 200 4 | ffffffff = 5000 5 | #else 6 | ffff = 0xffff 7 | ffffffff = 0xffffffff 8 | #endif 9 | -------------------------------------------------------------------------------- /data/examples/other/multiline-comments-reindent.hs: -------------------------------------------------------------------------------- 1 | {- 2 | And so here we have a 3 | multiline comment. 4 | 5 | Indeed. 6 | -} 7 | -------------------------------------------------------------------------------- /data/examples/other/pragma-comments-after.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -- TODO: Fix and delete this pragma 2 | {-# LANGUAGE AllowAmbiguousTypes #-} 3 | {-# LANGUAGE ConstraintKinds #-} 4 | -------------------------------------------------------------------------------- /data/diff-tests/outputs/simple-hunk.txt: -------------------------------------------------------------------------------- 1 | TEST 2 | @@ -1,7 +1,7 @@ 3 | module Main (main) where 4 | 5 | main :: IO () 6 | - main = return () 7 | + main = pure () 8 | 9 | foo :: Int 10 | foo = 5 11 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/type/unrelated.hs: -------------------------------------------------------------------------------- 1 | clientFunc1 :: SomeType1 2 | clientFunc2 :: SomeType2 3 | clientFunc3 :: SomeType3 4 | clientFunc1 :<|> clientFunc2 :<|> clientFunc3 = hoistClient foo bar baz 5 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/closed-type-family/injective.hs: -------------------------------------------------------------------------------- 1 | type family Id a = result | result -> a where 2 | Id a = a 3 | type family G (a :: k) b c = foo | foo -> k b where 4 | G a b c = (a, b) 5 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operator-sections.hs: -------------------------------------------------------------------------------- 1 | foo = (0 +) 2 | bar = ( <> "hello" ) 3 | baz = 4 | ( 1 * 2 5 | + ) 6 | ( * 7 | 3 ^ 5) 8 | 9 | quux = (,) <$> foo <$> bar 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/pattern-bind.hs: -------------------------------------------------------------------------------- 1 | foo = bar 2 | where 3 | Foo bar baz = quux 4 | Baz 5 | quux = zoo 6 | 7 | foo = bar 8 | where Foo bar baz = quux 9 | 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/unboxed-sums-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE UnboxedSums #-} 2 | 3 | foo = (# 1 | #) 4 | 5 | bar = (# | | 2 | #) 6 | 7 | baz = 8 | (# 9 | | | | 10 | | | | | 10 | #) 11 | -------------------------------------------------------------------------------- /data/examples/declaration/warning/warning-multiline-out.hs: -------------------------------------------------------------------------------- 1 | {-# WARNING 2 | test 3 | , foo 4 | [ "These are bad functions" 5 | , "Really bad!" 6 | ] 7 | #-} 8 | test :: IO () 9 | test = pure () 10 | -------------------------------------------------------------------------------- /data/examples/other/cpp/separation-0a-out.hs: -------------------------------------------------------------------------------- 1 | instance Stream s => Monad (ParsecT e s m) where 2 | return = pure 3 | (>>=) = pBind 4 | 5 | #if !(MIN_VERSION_base(4,13,0)) 6 | fail = Fail.fail 7 | #endif 8 | -------------------------------------------------------------------------------- /data/examples/other/following-comment-last-2-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Another datatype... 4 | data D' 5 | deriving (Show) 6 | -- ^ ...with two docstrings. 7 | 8 | -- more 9 | 10 | data B 11 | -------------------------------------------------------------------------------- /data/examples/other/following-comment-last-2.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Another datatype... 4 | data D' 5 | deriving (Show) 6 | -- ^ ...with two docstrings. 7 | 8 | -- more 9 | 10 | data B 11 | -------------------------------------------------------------------------------- /.github/workflows/build.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | 3 | cabal update 4 | cabal build exe:ormolu --enable-executable-static --ghc-options="-split-sections" 5 | 6 | cp $(find dist-newstyle -name ormolu -type f) . 7 | strip -s ormolu 8 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/type/unrelated-out.hs: -------------------------------------------------------------------------------- 1 | clientFunc1 :: SomeType1 2 | clientFunc2 :: SomeType2 3 | clientFunc3 :: SomeType3 4 | clientFunc1 :<|> clientFunc2 :<|> clientFunc3 = hoistClient foo bar baz 5 | -------------------------------------------------------------------------------- /data/examples/declaration/splice/quasiquote-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE QuasiQuotes #-} 2 | 3 | x = [foo| foo bar |] 4 | 5 | x = 6 | [e| foo 7 | bar {- -} 8 | |] 9 | 10 | [d| foo bar 11 | 12 | |] 13 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/closed-type-family/simple-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Documentation. 4 | type family F a :: * -> * where 5 | F Int = Double 6 | F Bool = Char 7 | F a = String 8 | -------------------------------------------------------------------------------- /data/examples/declaration/type-synonyms/simple.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Documentation. 4 | 5 | type Foo a b c = Bar c a b 6 | 7 | type a ~> b = TyFun a b -> Type 8 | 9 | type (a :+: b) c d e = () 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do/expr-out.hs: -------------------------------------------------------------------------------- 1 | quux = something $ do 2 | foo 3 | case x of 4 | 1 -> 10 5 | 2 -> 20 6 | bar 7 | if something 8 | then x 9 | else y 10 | baz 11 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/pattern-bind-out.hs: -------------------------------------------------------------------------------- 1 | foo = bar 2 | where 3 | Foo bar baz = quux 4 | Baz 5 | quux = zoo 6 | 7 | foo = bar 8 | where 9 | Foo bar baz = quux 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pragmas.hs: -------------------------------------------------------------------------------- 1 | sccfoo = {-# SCC foo#-} 1 2 | sccbar = {-# SCC "barbaz"#-} 3 | "hello" 4 | 5 | corefoo = {-# CORE "foo"#-} 1 6 | corebar = {-# CORE "bar baz"#-} 7 | "hello" 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/record/hanging-after-equal-con-out.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | Foo 3 | { foo = 4 | -- Blah blah 5 | case x of 6 | Blah -> 1 7 | Blim -> 2 8 | } 9 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/record/hanging-after-equal-update-out.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | foo 3 | { foo = 4 | -- Blah blah 5 | case x of 6 | Blah -> 1 7 | Blim -> 2 8 | } 9 | -------------------------------------------------------------------------------- /data/examples/other/disabling/indented-fragment-out.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | {- ORMOLU_DISABLE -} 3 | testCase "Foo" testFoo : 4 | testCase "Bar" testBar : 5 | testCase "Baz" testBaz : 6 | {- ORMOLU_ENABLE -} 7 | [] 8 | -------------------------------------------------------------------------------- /data/examples/other/pragma-comments-after-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE AllowAmbiguousTypes #-} 2 | {-# LANGUAGE ConstraintKinds #-} 3 | -- TODO: Fix and delete this pragma 4 | {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} 5 | -------------------------------------------------------------------------------- /data/examples/declaration/data/fat-multiline.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | 5 | data Foo 6 | = Foo Int 7 | Int 8 | -- ^ Foo 9 | | Bar Bool 10 | Bool 11 | -- ^ Bar 12 | -------------------------------------------------------------------------------- /data/examples/declaration/data/field-layout/variants.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Foo. 4 | 5 | data Foo = 6 | Foo Int Int 7 | -- ^ Something 8 | | Bar Char 9 | Char 10 | -- ^ Something else 11 | -------------------------------------------------------------------------------- /data/examples/declaration/data/strictness-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | data Foo 5 | = Foo1 !Int {-# UNPACK #-} !Bool {-# NOUNPACK #-} !String 6 | | Foo2 {a :: {-# UNPACK #-} Maybe Int && Bool} 7 | -------------------------------------------------------------------------------- /data/examples/declaration/data/strictness.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | 5 | data Foo 6 | = Foo1 !Int {-# UNPACK #-} !Bool {-# NOUNPACK #-} !String 7 | | Foo2 { a :: {-# UNPACK #-} Maybe Int && Bool } 8 | -------------------------------------------------------------------------------- /data/examples/declaration/rewrite-rule/forall-0.hs: -------------------------------------------------------------------------------- 1 | {-# RULES 2 | "fold/build" forall k z . foldr k z (build g) = g k z 3 | #-} 4 | 5 | {-# RULES 6 | "fusable/aux" forall x y. 7 | fusable x (aux y) = faux x y 8 | #-} 9 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/closed-type-family/injective-out.hs: -------------------------------------------------------------------------------- 1 | type family Id a = result | result -> a where 2 | Id a = a 3 | 4 | type family G (a :: k) b c = foo | foo -> k b where 5 | G a b c = (a, b) 6 | -------------------------------------------------------------------------------- /data/examples/declaration/type-families/closed-type-family/simple.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Documentation. 4 | 5 | type family F a :: * -> * where 6 | F Int = Double 7 | F Bool = Char 8 | F a = String 9 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/backticks-lhs.hs: -------------------------------------------------------------------------------- 1 | x `op1` (Just 0) = True 2 | op1 x (Just _) = False 3 | op1 x Nothing = undefined 4 | 5 | op2 1 y = False 6 | x `op2` y = 7 | True 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operator-sections-out.hs: -------------------------------------------------------------------------------- 1 | foo = (0 +) 2 | 3 | bar = (<> "hello") 4 | 5 | baz = 6 | (1 * 2 7 | +) 8 | (* 9 | 3 ^ 5) 10 | 11 | quux = (,) <$> foo <$> bar 12 | -------------------------------------------------------------------------------- /data/examples/module-header/warning-pragma-list-multiline.hs: -------------------------------------------------------------------------------- 1 | module Test {-# DEPRECATED ["This module is deprecated.", 2 | "Please use OtherModule instead." 3 | ]#-} 4 | ( foo 5 | , bar 6 | , baz 7 | ) 8 | where 9 | -------------------------------------------------------------------------------- /data/examples/other/disabling/indented-fragment.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | {- ORMOLU_DISABLE -} 3 | testCase "Foo" testFoo : 4 | testCase "Bar" testBar : 5 | testCase "Baz" testBaz : 6 | {- ORMOLU_ENABLE -} 7 | [] 8 | -------------------------------------------------------------------------------- /data/examples/declaration/class/default-signatures-simple-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | class Foo a where 5 | -- | Foo 6 | foo :: a -> String 7 | default foo :: Show a => a -> String 8 | foo = show 9 | -------------------------------------------------------------------------------- /data/examples/declaration/data/multiline.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Here we have 'Foo'. 4 | 5 | data Foo 6 | = Foo -- ^ One 7 | | Bar Int -- ^ Two 8 | | Baz -- ^ Three 9 | deriving 10 | (Eq, Show) 11 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/data-family-instances-newtype.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE GADTSyntax #-} 2 | {-# LANGUAGE TypeFamilies #-} 3 | newtype instance Foo [Double] = DoubleListFoo { 4 | unDoubleListFoo :: Double 5 | } 6 | 7 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/parenthesis-lhs-out.hs: -------------------------------------------------------------------------------- 1 | (!=!) 2 y = 1 2 | x !=! y = 2 3 | 4 | x ?=? [] = 123 5 | (?=?) x (_ : []) = 456 6 | x ?=? _ = f x x 7 | where 8 | f x 7 = 789 9 | x `f` _ = 101 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/record/updaters-out.hs: -------------------------------------------------------------------------------- 1 | foo x = x {a = 3} 2 | 3 | bar x = 4 | x 5 | { abc = foo 6 | , def = Foo {a = 10} 7 | } 8 | 9 | baz x = x {} 10 | 11 | sym x = x {(+) = 4} 12 | -------------------------------------------------------------------------------- /data/examples/import/nested-explicit-imports-out.hs: -------------------------------------------------------------------------------- 1 | import qualified MegaModule as M 2 | ( Either 3 | , Monad 4 | ( return 5 | , (>>) 6 | , (>>=) 7 | ) 8 | , (<<<) 9 | , (>>>) 10 | ) 11 | -------------------------------------------------------------------------------- /data/examples/other/comment-inside-construct-out.hs: -------------------------------------------------------------------------------- 1 | xs = 2 | [ outer list item 3 | , [ inner list first item 4 | , inner list second item 5 | -- inner list last item commented 6 | ] 7 | , outer list item 8 | ] 9 | -------------------------------------------------------------------------------- /data/examples/other/cpp/separation-2a-out.hs: -------------------------------------------------------------------------------- 1 | ffff, ffffffff :: Natural 2 | 3 | #ifdef HASKELL_ZIP_DEV_MODE 4 | ffff = 200 5 | ffffffff = 5000 6 | #else 7 | ffff = 0xffff 8 | ffffffff = 0xffffffff 9 | #endif 10 | -------------------------------------------------------------------------------- /data/examples/other/disabling/whole-file-out.hs: -------------------------------------------------------------------------------- 1 | {- ORMOLU_DISABLE -} 2 | 3 | module Foo (foo,bar) where 4 | 5 | foo :: Int -> Int 6 | foo = (+5) 7 | 8 | bar :: Bool -> Bool 9 | bar True = True 10 | bar False = True 11 | -------------------------------------------------------------------------------- /data/examples/declaration/class/default-signatures-simple.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | class Foo a where 5 | -- | Foo 6 | foo :: a -> String 7 | default foo :: Show a => a -> String 8 | foo = show 9 | -------------------------------------------------------------------------------- /data/examples/declaration/class/type-operators3.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TypeFamilies, TypeOperators, NoStarIsType, PolyKinds #-} 2 | 3 | class PNum x where 4 | type (a :: x) * (b :: x) 5 | 6 | instance PNum Nat where 7 | type a * b = () 8 | -------------------------------------------------------------------------------- /data/examples/declaration/data/field-layout/gadt.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Foo. 4 | 5 | data Foo a b where 6 | -- | Something 7 | Foo :: Foo Int Int 8 | -- | Something else 9 | Bar :: Foo Char 10 | Char 11 | -------------------------------------------------------------------------------- /data/examples/declaration/data/field-layout/variants-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Foo. 4 | data Foo 5 | = -- | Something 6 | Foo Int Int 7 | | -- | Something else 8 | Bar 9 | Char 10 | Char 11 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/data-family-instances-newtype-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE GADTSyntax #-} 2 | {-# LANGUAGE TypeFamilies #-} 3 | 4 | newtype instance Foo [Double] = DoubleListFoo 5 | { unDoubleListFoo :: Double 6 | } 7 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/type/multi-value.hs: -------------------------------------------------------------------------------- 1 | foo, bar :: Int 2 | foo = 1 3 | bar = 2 4 | 5 | a, b, c :: Int 6 | a = 1 7 | b = 2 8 | c = 3 9 | 10 | foo, 11 | bar, 12 | baz :: Int 13 | bar = 2 14 | baz = 3 15 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/parenthesis-lhs.hs: -------------------------------------------------------------------------------- 1 | (!=!) 2 y = 1 2 | x !=! y = 2 3 | 4 | x ?=? [] = 123 5 | (?=?) x (_:[]) = 456 6 | x ?=? _ = f x x 7 | where 8 | f x 7 = 789 9 | x `f` _ = 101 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/record/inter-comments-out.hs: -------------------------------------------------------------------------------- 1 | x = 2 | Just 3 | -- comment 4 | A 5 | { x 6 | } 7 | 8 | x = 9 | Just 10 | -- comment 11 | a 12 | { x 13 | } 14 | -------------------------------------------------------------------------------- /data/examples/import/deduplication-bug-out.hs: -------------------------------------------------------------------------------- 1 | import Foo1 (Bar1 (..), Baz1) 2 | import Foo2 (Bar2 (..), Baz2) 3 | import Foo3 (Bar3 (x1, x2, x3)) 4 | import Foo4 (Bar4 (x1, x2)) 5 | import Foo5 (Bar5 (x1)) 6 | import Foo6 (Bar6 (..)) 7 | -------------------------------------------------------------------------------- /data/examples/other/disabling/whole-file.hs: -------------------------------------------------------------------------------- 1 | {- ORMOLU_DISABLE -} 2 | 3 | module Foo (foo,bar) where 4 | 5 | foo :: Int -> Int 6 | foo = (+5) 7 | 8 | bar :: Bool -> Bool 9 | bar True = True 10 | bar False = True 11 | -------------------------------------------------------------------------------- /data/examples/declaration/data/fat-multiline-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | data Foo 5 | = -- | Foo 6 | Foo 7 | Int 8 | Int 9 | | -- | Bar 10 | Bar 11 | Bool 12 | Bool 13 | -------------------------------------------------------------------------------- /data/examples/declaration/splice/bracket.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | foo = [| foo bar 4 | |] 5 | 6 | foo = [e| foo bar 7 | |] 8 | 9 | foo = [t| Char |] 10 | 11 | foo = [|| foo bar 12 | ||] 13 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/application-1.hs: -------------------------------------------------------------------------------- 1 | main = 2 | do 3 | x 4 | y 5 | z 6 | 7 | main = 8 | case foo of 9 | x -> a 10 | foo a b 11 | 12 | main = do 13 | if x then y else z 14 | foo a b 15 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/tuples.hs: -------------------------------------------------------------------------------- 1 | foo = ( 1,2,3 ) 2 | bar = ( 3 | 1, 4 | 2, 5 | 3 6 | ) 7 | 8 | handleStuff = 9 | ( let foo = foo 10 | in foo 11 | , let bar = bar 12 | in bar 13 | ) 14 | -------------------------------------------------------------------------------- /data/examples/declaration/data/simple-broken-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Here we go. 4 | data Foo = Foo {unFoo :: Int} 5 | deriving (Eq) 6 | 7 | -- | And once again. 8 | data Bar = Bar {unBar :: Int} 9 | deriving (Eq) 10 | -------------------------------------------------------------------------------- /data/examples/declaration/rewrite-rule/forall-0-out.hs: -------------------------------------------------------------------------------- 1 | {-# RULES 2 | "fold/build" forall k z. foldr k z (build g) = g k z 3 | #-} 4 | 5 | {-# RULES 6 | "fusable/aux" forall x y. 7 | fusable x (aux y) = 8 | faux x y 9 | #-} 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/application-0-out.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | f1 3 | p1 4 | p2 5 | p3 6 | 7 | foo' = 8 | f2 9 | p1 10 | p2 11 | p3 12 | 13 | foo'' = 14 | f3 15 | p1 16 | p2 17 | p3 18 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/lambda-case.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE LambdaCase #-} 2 | 3 | foo = bar (\case JKey{} -> True; _ -> False) 4 | 5 | foo :: Int -> Int 6 | foo = \case 7 | 5 -> 10 8 | i | i > 5 -> 11 9 | _ -> 12 10 | -------------------------------------------------------------------------------- /data/examples/other/argument-comment.hs: -------------------------------------------------------------------------------- 1 | foo 2 | :: Int -- ^ Documentation 3 | -> Bool 4 | foo _ = True 5 | 6 | foo :: Foo a 7 | => Int -- ^ Foo 8 | -> Int 9 | 10 | foo 11 | :: Foo a 12 | => Int -- ^ Foo 13 | -> Int 14 | -------------------------------------------------------------------------------- /expected-failures/idris.txt: -------------------------------------------------------------------------------- 1 | src/Idris/Parser.hs:1052:1 2 | The GHC parser (in Haddock mode) failed: 3 | parse error on input `@' 4 | src/Idris/Parser/Expr.hs:75:1 5 | The GHC parser (in Haddock mode) failed: 6 | parse error on input `@' 7 | -------------------------------------------------------------------------------- /data/examples/declaration/class/super-classes.hs: -------------------------------------------------------------------------------- 1 | class () => Foo a 2 | class Foo a => Bar a 3 | class (Foo a,Bar a) => 4 | Baz a 5 | class ( 6 | Foo a, -- Foo? 7 | Bar a, -- Bar? 8 | Baz a -- Baz 9 | ) => BarBar a 10 | -------------------------------------------------------------------------------- /data/examples/declaration/role-annotation/multi-line-out.hs: -------------------------------------------------------------------------------- 1 | type role 2 | D 3 | phantom 4 | nominal 5 | 6 | type role 7 | E 8 | _ 9 | nominal 10 | 11 | type role 12 | E 13 | _ 14 | nominal 15 | phantom 16 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/type/multi-value-out.hs: -------------------------------------------------------------------------------- 1 | foo, bar :: Int 2 | foo = 1 3 | bar = 2 4 | 5 | a, b, c :: Int 6 | a = 1 7 | b = 2 8 | c = 3 9 | 10 | foo 11 | , bar 12 | , baz 13 | :: Int 14 | bar = 2 15 | baz = 3 16 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/lambda-case-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE LambdaCase #-} 2 | 3 | foo = bar (\case JKey {} -> True; _ -> False) 4 | 5 | foo :: Int -> Int 6 | foo = \case 7 | 5 -> 10 8 | i | i > 5 -> 11 9 | _ -> 12 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/overindentation.hs: -------------------------------------------------------------------------------- 1 | reallyincrediblyLongName = f 2 | a 3 | A 4 | { reallyincrediblyLongName = f 5 | a 6 | A 7 | { reallyincrediblyLongName 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/tuples-out.hs: -------------------------------------------------------------------------------- 1 | foo = (1, 2, 3) 2 | 3 | bar = 4 | ( 1 5 | , 2 6 | , 3 7 | ) 8 | 9 | handleStuff = 10 | ( let foo = foo 11 | in foo 12 | , let bar = bar 13 | in bar 14 | ) 15 | -------------------------------------------------------------------------------- /data/examples/module-header/named-section.hs: -------------------------------------------------------------------------------- 1 | module Magic 2 | ( -- * Something 3 | -- $explanation 4 | 5 | -- ** Another level 6 | foo 7 | , bar 8 | ) 9 | where 10 | 11 | -- $explanation 12 | -- 13 | -- Here it goes. 14 | -------------------------------------------------------------------------------- /data/examples/other/argument-comment-out.hs: -------------------------------------------------------------------------------- 1 | foo 2 | :: Int -- ^ Documentation 3 | -> Bool 4 | foo _ = True 5 | 6 | foo 7 | :: Foo a 8 | => Int -- ^ Foo 9 | -> Int 10 | foo 11 | :: Foo a 12 | => Int -- ^ Foo 13 | -> Int 14 | -------------------------------------------------------------------------------- /data/examples/other/comment-inside-construct.hs: -------------------------------------------------------------------------------- 1 | xs = 2 | [ outer list item, 3 | [ inner list first item, 4 | inner list second item 5 | -- inner list last item commented 6 | ], 7 | outer list item 8 | ] 9 | 10 | -------------------------------------------------------------------------------- /data/examples/declaration/data/multiline-arg-parens-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | data Foo 5 | = Foo 6 | Bar 7 | (Set Baz) -- and here we go 8 | -- and that's it 9 | Text 10 | deriving (Eq) 11 | -------------------------------------------------------------------------------- /data/examples/declaration/data/multiline-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Here we have 'Foo'. 4 | data Foo 5 | = -- | One 6 | Foo 7 | | -- | Two 8 | Bar Int 9 | | -- | Three 10 | Baz 11 | deriving 12 | (Eq, Show) 13 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/case-single-line.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int 2 | foo x = case x of x -> x 3 | 4 | foo :: IO () 5 | foo = case [1] of [_] -> "singleton"; _ -> "not singleton" 6 | foo = case [1] of { [] -> foo; _ -> bar } `finally` baz 7 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do/comment-alignment.hs: -------------------------------------------------------------------------------- 1 | main = do 2 | case blah of 3 | Nothing -> return () 4 | Just xs -> do 5 | forM_ xs foo 6 | bar 7 | -- and here it goes 8 | unless bobla $ 9 | quux 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/n-plus-k-pattern.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NPlusKPatterns #-} 2 | singleline :: Int 3 | singleline (n + 1) = n 4 | 5 | multiline :: Int 6 | multiline(n 7 | + 1) = n 8 | 9 | n :: Int 10 | (n + 1) = 3 11 | -------------------------------------------------------------------------------- /data/examples/module-header/named-section-out.hs: -------------------------------------------------------------------------------- 1 | module Magic 2 | ( -- * Something 3 | -- $explanation 4 | 5 | -- ** Another level 6 | foo 7 | , bar 8 | ) 9 | where 10 | 11 | -- $explanation 12 | -- 13 | -- Here it goes. 14 | -------------------------------------------------------------------------------- /data/examples/other/cpp/separation-0b.hs: -------------------------------------------------------------------------------- 1 | instance Stream s => Monad (ParsecT e s m) where 2 | return = pure 3 | (>>=) = pBind 4 | #if !(MIN_VERSION_base(4,13,0)) 5 | fail = Fail.fail 6 | #endif 7 | 8 | foo :: Int 9 | foo = undefined 10 | -------------------------------------------------------------------------------- /data/examples/other/disabling/single-definition-out.hs: -------------------------------------------------------------------------------- 1 | module Foo (foo, bar) where 2 | 3 | {- ORMOLU_DISABLE -} 4 | foo :: Int -> Int 5 | foo = (+5) 6 | {- ORMOLU_ENABLE -} 7 | 8 | bar :: Bool -> Bool 9 | bar True = True 10 | bar False = True 11 | -------------------------------------------------------------------------------- /data/examples/other/disabling/single-definition.hs: -------------------------------------------------------------------------------- 1 | module Foo (foo,bar) where 2 | 3 | {- ORMOLU_DISABLE -} 4 | foo :: Int -> Int 5 | foo = (+5) 6 | {- ORMOLU_ENABLE -} 7 | 8 | bar :: Bool -> Bool 9 | bar True = True 10 | bar False = True 11 | -------------------------------------------------------------------------------- /data/examples/declaration/data/field-layout/record.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Foo. 4 | 5 | data Foo = Foo 6 | { foo :: Foo Int Int 7 | -- ^ Something 8 | , bar :: Bar Char 9 | Char 10 | -- ^ Something else 11 | } 12 | -------------------------------------------------------------------------------- /data/examples/declaration/data/multiline-arg-parens.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | 5 | data Foo 6 | = Foo Bar 7 | (Set Baz) -- and here we go 8 | -- and that's it 9 | Text 10 | deriving (Eq) 11 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/single-parameter-out.hs: -------------------------------------------------------------------------------- 1 | instance Monoid Int where (<>) x y = x + y 2 | 3 | instance Enum Int where 4 | fromEnum x = x 5 | toEnum = 6 | \x -> 7 | x 8 | 9 | instance Foo Int where foo x = x; bar y = y 10 | -------------------------------------------------------------------------------- /data/examples/declaration/role-annotation/multi-line.hs: -------------------------------------------------------------------------------- 1 | type role 2 | D phantom nominal 3 | 4 | type 5 | role 6 | E 7 | _ 8 | nominal 9 | 10 | type 11 | role 12 | E 13 | _ 14 | nominal 15 | phantom 16 | -------------------------------------------------------------------------------- /data/examples/declaration/role-annotation/single-line.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE RoleAnnotations #-} 2 | {-# LANGUAGE MagicHash #-} 3 | 4 | type role Ptr representational 5 | 6 | type role A nominal nominal 7 | 8 | type role B _ phantom 9 | type role C _ _ 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/arrow/proc-parentheses-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Arrows #-} 2 | 3 | foo f = proc a -> (f -< a) 4 | 5 | bar f g = proc a -> 6 | (((f) 7 | (g)) 8 | -< 9 | ((((((g 10 | a))))))) 11 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/case-single-line-out.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int 2 | foo x = case x of x -> x 3 | 4 | foo :: IO () 5 | foo = case [1] of [_] -> "singleton"; _ -> "not singleton" 6 | foo = case [1] of { [] -> foo; _ -> bar } `finally` baz 7 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do/comment-alignment-out.hs: -------------------------------------------------------------------------------- 1 | main = do 2 | case blah of 3 | Nothing -> return () 4 | Just xs -> do 5 | forM_ xs foo 6 | bar 7 | -- and here it goes 8 | unless bobla $ 9 | quux 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do/recursive-do-mdo-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE RecursiveDo #-} 2 | 3 | baz = 4 | mdo 5 | bar a 6 | a <- foo 7 | b <- 8 | bar 9 | 1 10 | 2 11 | 3 12 | return (a + b) 13 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/famous-cardano-pattern.hs: -------------------------------------------------------------------------------- 1 | ( getNodeSettingsR 2 | :<|> getNodeInfoR 3 | :<|> getNextUpdateR 4 | :<|> restartNodeR 5 | ):<|>( getUtxoR 6 | :<|> getConfirmedProposalsR 7 | ) = client nodeV1Api 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pragmas-out.hs: -------------------------------------------------------------------------------- 1 | sccfoo = {-# SCC foo #-} 1 2 | 3 | sccbar = 4 | {-# SCC "barbaz" #-} 5 | "hello" 6 | 7 | corefoo = {-# CORE "foo" #-} 1 8 | 9 | corebar = 10 | {-# CORE "bar baz" #-} 11 | "hello" 12 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/record/dot-multiline.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS_GHC -fplugin=RecordDotPreprocessor #-} 2 | bar' = (Foo 1){bar = 2 3 | } 4 | 5 | fooplus'''' f n = f{foo = n, 6 | bar = n 7 | } 8 | -------------------------------------------------------------------------------- /data/examples/other/cpp/separation-2b.hs: -------------------------------------------------------------------------------- 1 | ffff, ffffffff :: Natural 2 | #ifdef HASKELL_ZIP_DEV_MODE 3 | ffff = 200 4 | ffffffff = 5000 5 | #else 6 | ffff = 0xffff 7 | ffffffff = 0xffffffff 8 | #endif 9 | 10 | foo :: Int 11 | foo = undefined 12 | -------------------------------------------------------------------------------- /data/examples/other/overly-indented-out.hs: -------------------------------------------------------------------------------- 1 | tagCloudField 2 | :: String -- ^ Destination key 3 | -> Double -- ^ Smallest font size, in percent 4 | -> Double -- ^ Biggest font size, in percent 5 | -> Tags -- ^ Input tags 6 | -> Context a -- ^ Context 7 | -------------------------------------------------------------------------------- /data/examples/declaration/class/newlines-and-default-decls-out.hs: -------------------------------------------------------------------------------- 1 | class Foo a where 2 | foo :: a 3 | default foo :: () 4 | foo = () 5 | bar :: a 6 | default bar :: () 7 | bar = () 8 | 9 | qux :: a 10 | default qux :: () 11 | qux = () 12 | -------------------------------------------------------------------------------- /data/examples/declaration/data/field-layout/gadt-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Foo. 4 | data Foo a b where 5 | -- | Something 6 | Foo :: Foo Int Int 7 | -- | Something else 8 | Bar 9 | :: Foo 10 | Char 11 | Char 12 | -------------------------------------------------------------------------------- /data/examples/declaration/data/simple-broken.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Here we go. 4 | 5 | data Foo 6 | = Foo { unFoo :: Int } 7 | deriving (Eq) 8 | 9 | -- | And once again. 10 | 11 | data Bar = Bar { unBar :: Int } 12 | deriving (Eq) 13 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/instance-sigs-multiple-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE InstanceSigs #-} 2 | 3 | instance Applicative [] where 4 | pure 5 | :: a 6 | -> [a] 7 | pure a = [a] 8 | (<*>) 9 | :: [a] -> [a] -> [a] 10 | (<*>) _ _ = [] 11 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/infix/do.hs: -------------------------------------------------------------------------------- 1 | main = 2 | do stuff 3 | `finally` do 4 | recover 5 | 6 | main = do stuff `finally` recover 7 | 8 | main = do { stuff } `finally` recover 9 | 10 | foo = do 11 | 1 12 | + 13 | 2 14 | -------------------------------------------------------------------------------- /data/examples/other/cpp/separation-0b-out.hs: -------------------------------------------------------------------------------- 1 | instance Stream s => Monad (ParsecT e s m) where 2 | return = pure 3 | (>>=) = pBind 4 | 5 | #if !(MIN_VERSION_base(4,13,0)) 6 | fail = Fail.fail 7 | #endif 8 | 9 | foo :: Int 10 | foo = undefined 11 | -------------------------------------------------------------------------------- /data/examples/other/cpp/separation-2b-out.hs: -------------------------------------------------------------------------------- 1 | ffff, ffffffff :: Natural 2 | #ifdef HASKELL_ZIP_DEV_MODE 3 | ffff = 200 4 | ffffffff = 5000 5 | #else 6 | ffff = 0xffff 7 | ffffffff = 0xffffffff 8 | #endif 9 | 10 | foo :: Int 11 | foo = undefined 12 | -------------------------------------------------------------------------------- /src/GHC.hs: -------------------------------------------------------------------------------- 1 | module GHC 2 | ( module X, 3 | ) 4 | where 5 | 6 | import ApiAnnotation as X 7 | import BasicTypes as X 8 | import GHC.Hs as X 9 | import GHC.Hs.Instances as X () 10 | import Module as X 11 | import RdrName as X 12 | import SrcLoc as X 13 | -------------------------------------------------------------------------------- /data/examples/declaration/class/default-implementations-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Foo 4 | class Foo a where 5 | foo :: a -> a 6 | foo a = a 7 | 8 | -- | Bar 9 | class Bar a where 10 | bar 11 | :: a 12 | -> Int 13 | bar = const 0 14 | -------------------------------------------------------------------------------- /data/examples/declaration/class/super-classes-out.hs: -------------------------------------------------------------------------------- 1 | class Foo a 2 | 3 | class Foo a => Bar a 4 | 5 | class 6 | (Foo a, Bar a) => 7 | Baz a 8 | 9 | class 10 | ( Foo a -- Foo? 11 | , Bar a -- Bar? 12 | , Baz a -- Baz 13 | ) => 14 | BarBar a 15 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/instance-sigs-multiple.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE InstanceSigs #-} 2 | 3 | instance Applicative [] where 4 | pure :: 5 | a 6 | -> [a] 7 | pure a = [a] 8 | (<*>) 9 | :: [ a ] -> [ a ] -> [ a ] 10 | (<*>) _ _ = [] 11 | -------------------------------------------------------------------------------- /data/examples/declaration/role-annotation/single-line-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MagicHash #-} 2 | {-# LANGUAGE RoleAnnotations #-} 3 | 4 | type role Ptr representational 5 | 6 | type role A nominal nominal 7 | 8 | type role B _ phantom 9 | 10 | type role C _ _ 11 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/inline/noinline-out.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int 2 | foo = id 3 | {-# NOINLINE foo #-} 4 | 5 | {-# NOINLINE [2] bar #-} 6 | bar :: Int -> Int 7 | bar = id 8 | 9 | baz :: Int -> Int 10 | baz = id 11 | {-# NOINLINE [~2] baz #-} 12 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/infix/do-out.hs: -------------------------------------------------------------------------------- 1 | main = 2 | do stuff 3 | `finally` do 4 | recover 5 | 6 | main = do stuff `finally` recover 7 | 8 | main = do { stuff } `finally` recover 9 | 10 | foo = 11 | do 12 | 1 13 | + 2 14 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/list-notation-2-out.hs: -------------------------------------------------------------------------------- 1 | -- A list of the element and all its parents up to the root node. 2 | getPath tree t = 3 | t : 4 | case Map.lookup (getId t) tree of 5 | Nothing -> [] 6 | Just parent -> getPath tree parent 7 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/list-notation-2.hs: -------------------------------------------------------------------------------- 1 | -- A list of the element and all its parents up to the root node. 2 | getPath tree t = t : 3 | case Map.lookup (getId t) tree of 4 | Nothing -> [] 5 | Just parent -> getPath tree parent 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/quasi-quotes.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE QuasiQuotes #-} 2 | singleline :: Value 3 | singleline = [yamlQQ|something|] 4 | 5 | multiline :: Value 6 | multiline = [yamlQQ| name: John Doe 7 | age: 23 8 | 9 | something: foo 10 | |] 11 | -------------------------------------------------------------------------------- /data/examples/import/deduplication-bug.hs: -------------------------------------------------------------------------------- 1 | import Foo1 (Bar1, Baz1, Bar1(..)) 2 | import Foo2 (Bar2(..), Baz2, Bar2) 3 | import Foo3 (Bar3(x1,x3), Bar3(x1, x2)) 4 | import Foo4 (Bar4(x1), Bar4(x2)) 5 | import Foo5 (Bar5, Bar5(x1)) 6 | import Foo6 (Bar6(x1), Bar6(..)) 7 | -------------------------------------------------------------------------------- /data/examples/module-header/warning-pragma-list-multiline-out.hs: -------------------------------------------------------------------------------- 1 | module Test 2 | {-# DEPRECATED 3 | [ "This module is deprecated." 4 | , "Please use OtherModule instead." 5 | ] 6 | #-} 7 | ( foo 8 | , bar 9 | , baz 10 | ) 11 | where 12 | -------------------------------------------------------------------------------- /expected-failures/distributed-process.txt: -------------------------------------------------------------------------------- 1 | benchmarks/Channels.hs:2:1-6 2 | The GHC parser (in Haddock mode) failed: 3 | parse error on input `import' 4 | benchmarks/Spawns.hs:5:1-6 5 | The GHC parser (in Haddock mode) failed: 6 | parse error on input `import' 7 | -------------------------------------------------------------------------------- /data/examples/declaration/class/newlines-and-default-decls.hs: -------------------------------------------------------------------------------- 1 | class Foo a where 2 | foo :: a 3 | default foo :: () 4 | foo = () 5 | bar :: a 6 | default bar :: () 7 | bar = () 8 | 9 | qux :: a 10 | 11 | default qux :: () 12 | 13 | qux = () 14 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/single-parameter.hs: -------------------------------------------------------------------------------- 1 | instance Monoid Int where (<>) x y = x+y 2 | 3 | instance Enum Int 4 | where 5 | fromEnum x = x 6 | toEnum 7 | = \x -> 8 | x 9 | 10 | instance Foo Int where { foo x = x; bar y = y } 11 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/complete/complete.hs: -------------------------------------------------------------------------------- 1 | {-# ComPlETe A , B, C:: Foo 2 | 3 | #-} 4 | 5 | {-# COMPLETE A , B 6 | #-} 7 | 8 | {-# ComPlETE 9 | A , 10 | B, C 11 | 12 | 13 | :: Foo#-} 14 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/inline/inlineable-out.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int 2 | foo = id 3 | {-# INLINEABLE foo #-} 4 | 5 | {-# INLINEABLE [2] bar #-} 6 | bar :: Int -> Int 7 | bar = id 8 | 9 | baz :: Int -> Int 10 | baz = id 11 | {-# INLINEABLE [~2] baz #-} 12 | -------------------------------------------------------------------------------- /data/examples/declaration/type/promotion-0.hs: -------------------------------------------------------------------------------- 1 | type Foo = Cluster '[ 'NodeCore, 'NodeRelay', 'NodeEdge ] 2 | 3 | type Query = Query '[] '[] DB '[ 'NotNull 'PGint4] (RowPG RawElementData) 4 | 5 | data T = T' | T'T 6 | 7 | type S0 = ' T' 8 | 9 | type S1 = ' T'T 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/comprehension/transform-multi-line1.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TransformListComp #-} 2 | 3 | foo' xs ys = [ 4 | (x, 5 | y) | 6 | x <- xs, 7 | y <- ys, 8 | then -- First comment 9 | reverse -- Second comment 10 | ] 11 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/record/dot-multiline-out.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS_GHC -fplugin=RecordDotPreprocessor #-} 2 | 3 | bar' = 4 | (Foo 1) 5 | { bar = 2 6 | } 7 | 8 | fooplus'''' f n = 9 | f 10 | { foo = n 11 | , bar = n 12 | } 13 | -------------------------------------------------------------------------------- /data/diff-tests/outputs/joined-hunk.txt: -------------------------------------------------------------------------------- 1 | TEST 2 | @@ -1,11 +1,11 @@ 3 | module Main (main) where 4 | 5 | main :: IO () 6 | - main = return () 7 | + main = pure () 8 | 9 | foo :: Int 10 | foo = 11 | 5 12 | 13 | bar :: Int 14 | - bar = 6 15 | + bar = 7 16 | -------------------------------------------------------------------------------- /data/examples/declaration/data/field-layout/record-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Foo. 4 | data Foo = Foo 5 | { -- | Something 6 | foo :: Foo Int Int 7 | , -- | Something else 8 | bar 9 | :: Bar 10 | Char 11 | Char 12 | } 13 | -------------------------------------------------------------------------------- /data/examples/declaration/splice/bracket-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | foo = 4 | [| 5 | foo bar 6 | |] 7 | 8 | foo = 9 | [e| 10 | foo bar 11 | |] 12 | 13 | foo = [t|Char|] 14 | 15 | foo = 16 | [|| 17 | foo bar 18 | ||] 19 | -------------------------------------------------------------------------------- /data/examples/declaration/splice/quotes-out.hs: -------------------------------------------------------------------------------- 1 | foo = ''R 2 | 3 | bar = 'foo 4 | 5 | bar' = 'foo_bar 6 | 7 | baz = ''(:#) 8 | 9 | baz' = ''(Foo.Bar.:#) 10 | 11 | equals = ''(==) 12 | 13 | unit = ''() 14 | 15 | list = ''[] 16 | 17 | quolified = ''Semigroup.Option 18 | -------------------------------------------------------------------------------- /data/examples/declaration/splice/quotes.hs: -------------------------------------------------------------------------------- 1 | foo = ''R 2 | 3 | bar = 'foo 4 | 5 | bar' = 'foo_bar 6 | 7 | baz = ''(:#) 8 | 9 | baz' = ''(Foo.Bar.:#) 10 | 11 | equals = ''(==) 12 | 13 | unit = ''() 14 | 15 | list = ''[] 16 | 17 | quolified = ''Semigroup.Option 18 | -------------------------------------------------------------------------------- /data/examples/declaration/type/promotion-0-out.hs: -------------------------------------------------------------------------------- 1 | type Foo = Cluster '[ 'NodeCore, 'NodeRelay', 'NodeEdge] 2 | 3 | type Query = Query '[] '[] DB '[ 'NotNull 'PGint4] (RowPG RawElementData) 4 | 5 | data T = T' | T'T 6 | 7 | type S0 = ' T' 8 | 9 | type S1 = ' T'T 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/application-1-out.hs: -------------------------------------------------------------------------------- 1 | main = 2 | do 3 | x 4 | y 5 | z 6 | 7 | main = 8 | case foo of 9 | x -> a 10 | foo 11 | a 12 | b 13 | 14 | main = 15 | do 16 | if x then y else z 17 | foo 18 | a 19 | b 20 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/arrow/proc-lambdas-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Arrows #-} 2 | 3 | foo = proc a -> \f b -> a -< f b -- Foo 4 | 5 | bar = 6 | proc x -> \f g h -> 7 | \() -> 8 | \(Left (x, y)) -> -- Tuple value 9 | f (g (h x)) -< y 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operators-6.hs: -------------------------------------------------------------------------------- 1 | type PermuteRef = 2 | "a" :> ( "b" :> "c" :> End 3 | :<|> "c" :> "b" :> End 4 | ) 5 | :<|> "b" :> ( "a" :> "c" :> End 6 | :<|> "c" :> "a" :> End 7 | ) 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/record/wildcards.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NamedFieldPuns #-} 2 | {-# LANGUAGE RecordWildCards #-} 3 | 4 | foo x y = Foo { x, y } 5 | 6 | bar x y z = Bar { 7 | x, 8 | y, 9 | z, 10 | .. 11 | } 12 | 13 | baz = Baz { .. } 14 | -------------------------------------------------------------------------------- /data/examples/declaration/class/default-implementations.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Foo 4 | class Foo a where 5 | foo :: a -> a 6 | foo a = a 7 | 8 | -- | Bar 9 | class Bar a where 10 | bar :: 11 | a 12 | -> Int 13 | bar = const 0 14 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/inline/noinline.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int 2 | foo = id 3 | {-# NOINLINE foo #-} 4 | 5 | {-# NOINLINE [2] bar #-} 6 | 7 | bar :: Int -> Int 8 | bar = id 9 | 10 | baz :: Int -> Int 11 | baz = id 12 | 13 | {-# NOINLINE [~2] baz #-} 14 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operators-6-out.hs: -------------------------------------------------------------------------------- 1 | type PermuteRef = 2 | "a" 3 | :> ( "b" :> "c" :> End 4 | :<|> "c" :> "b" :> End 5 | ) 6 | :<|> "b" 7 | :> ( "a" :> "c" :> End 8 | :<|> "c" :> "a" :> End 9 | ) 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/famous-cardano-pattern-out.hs: -------------------------------------------------------------------------------- 1 | ( getNodeSettingsR 2 | :<|> getNodeInfoR 3 | :<|> getNextUpdateR 4 | :<|> restartNodeR 5 | ) 6 | :<|> ( getUtxoR 7 | :<|> getConfirmedProposalsR 8 | ) = client nodeV1Api 9 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/n-plus-k-pattern-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NPlusKPatterns #-} 2 | 3 | singleline :: Int 4 | singleline (n + 1) = n 5 | 6 | multiline :: Int 7 | multiline 8 | ( n 9 | + 1 10 | ) = n 11 | 12 | n :: Int 13 | (n + 1) = 3 14 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/quasi-quotes-pattern.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE QuasiQuotes #-} 2 | singleline :: () 3 | singleline [yamlQQ|something|] = () 4 | 5 | multiline :: () 6 | multiline = case y of 7 | [yamlQQ| name: John Doe 8 | age: 23 9 | |] -> () 10 | -------------------------------------------------------------------------------- /expected-failures/tensorflow.txt: -------------------------------------------------------------------------------- 1 | tensorflow-mnist/app/Main.hs:50:13-14 2 | The GHC parser (in Haddock mode) failed: 3 | parse error on input `->' 4 | tensorflow-ops/tests/RegressionTest.hs:3:1-6 5 | The GHC parser (in Haddock mode) failed: 6 | parse error on input `import' 7 | -------------------------------------------------------------------------------- /data/examples/declaration/class/associated-data1-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TypeFamilies #-} 2 | 3 | class Foo a where data FooBar a 4 | 5 | -- | Something. 6 | class Bar a where 7 | -- | Bar bar 8 | data BarBar a 9 | 10 | -- | Bar baz 11 | data 12 | BarBaz 13 | a 14 | -------------------------------------------------------------------------------- /data/examples/declaration/class/associated-types1-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TypeFamilies #-} 2 | 3 | class Foo a where type FooBar a 4 | 5 | -- | Something. 6 | class Bar a where 7 | -- | Bar bar 8 | type BarBar a 9 | 10 | -- | Bar baz 11 | type 12 | BarBaz 13 | a 14 | -------------------------------------------------------------------------------- /data/examples/declaration/class/associated-types1.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TypeFamilies #-} 2 | 3 | class Foo a where type FooBar a 4 | 5 | -- | Something. 6 | class Bar a 7 | where 8 | -- | Bar bar 9 | type BarBar a 10 | -- | Bar baz 11 | type BarBaz 12 | a 13 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/minimal/minimal.hs: -------------------------------------------------------------------------------- 1 | class Foo a where 2 | 3 | {-# MINIMAL (==) |( (/=) , foo) #-} 4 | 5 | {-# MINIMAL a | (b , c , d | e 6 | , f) 7 | | g #-} 8 | 9 | (==) :: a -> a -> Bool 10 | (/=) :: a -> a -> Bool 11 | -------------------------------------------------------------------------------- /data/examples/declaration/splice/splice-decl-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | $(foo bar) 4 | 5 | $foo 6 | 7 | $$(foo bar) 8 | 9 | $$foo 10 | 11 | foo bar 12 | 13 | [|booya|] 14 | 15 | -- TemplateHaskell allows Q () at the top level 16 | do 17 | pure [] 18 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/arrow/proc-lambdas.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Arrows #-} 2 | 3 | foo = proc a-> \f b->a- 7 | \f g h -> 8 | \() -> 9 | \( Left (x,y )) -> -- Tuple value 10 | f (g (h x)) -< y 11 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/arrow/proc-parentheses.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Arrows #-} 2 | foo f = proc a -> ( f -< a ) 3 | 4 | bar f g = proc a -> 5 | ( ((f) ( 6 | g 7 | )) 8 | -< ((((( 9 | (g 10 | a) 11 | ))))) 12 | ) 13 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/quasi-quotes-pattern-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE QuasiQuotes #-} 2 | 3 | singleline :: () 4 | singleline [yamlQQ|something|] = () 5 | 6 | multiline :: () 7 | multiline = case y of 8 | [yamlQQ| name: John Doe 9 | age: 23 10 | |] -> () 11 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/splice-pattern.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | singleLine = case () of 4 | $x -> () 5 | $(y "something") -> () 6 | 7 | multiline = case () of 8 | $(x 9 | + y) -> () 10 | $(y 11 | "something") -> () 12 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/quasi-quotes-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE QuasiQuotes #-} 2 | 3 | singleline :: Value 4 | singleline = [yamlQQ|something|] 5 | 6 | multiline :: Value 7 | multiline = 8 | [yamlQQ| name: John Doe 9 | age: 23 10 | 11 | something: foo 12 | |] 13 | -------------------------------------------------------------------------------- /data/examples/declaration/class/associated-data1.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TypeFamilies #-} 2 | 3 | class Foo a where data FooBar a 4 | 5 | -- | Something. 6 | class Bar a 7 | where 8 | -- | Bar bar 9 | data BarBar a 10 | -- | Bar baz 11 | data family BarBaz 12 | a 13 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/inline/inlineable.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int 2 | foo = id 3 | 4 | {-# INLINEABLE foo #-} 5 | 6 | {-# INLINEABLE [2] bar #-} 7 | 8 | bar :: Int -> Int 9 | bar = id 10 | 11 | baz :: Int -> Int 12 | baz = id 13 | {-# INLINEABLE [~2] baz #-} 14 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/arrow/proc-lets-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Arrows #-} 2 | 3 | foo f = proc a -> let b = a in f -< b 4 | 5 | bar f g = proc a -> 6 | let h = 7 | f 8 | . g a 9 | j = 10 | g 11 | . h 12 | in id -< (h, j) 13 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do/hang-rhs-arrow-out.hs: -------------------------------------------------------------------------------- 1 | foo = do 2 | something <- case bar of 3 | Foo -> return 1 4 | Bar -> return 2 5 | somethingElse <- 6 | case boom of 7 | Foo -> return 1 8 | Bar -> return 2 9 | quux something somethingElse 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do/hang-rhs-arrow.hs: -------------------------------------------------------------------------------- 1 | foo = do 2 | something <- case bar of 3 | Foo -> return 1 4 | Bar -> return 2 5 | somethingElse <- 6 | case boom of 7 | Foo -> return 1 8 | Bar -> return 2 9 | quux something somethingElse 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/infix/simple.hs: -------------------------------------------------------------------------------- 1 | (*) :: Int -> Int -> Int 2 | x * y = z 3 | 4 | foo :: Int -> Int -> Int 5 | x `foo` y = z 6 | 7 | bar :: Int -> Int -> Int -> Int 8 | (x `bar` y) z = z 9 | 10 | multiline :: Int -> Int -> Int 11 | x `multiline` 12 | y = z 13 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/record/wildcards-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NamedFieldPuns #-} 2 | {-# LANGUAGE RecordWildCards #-} 3 | 4 | foo x y = Foo {x, y} 5 | 6 | bar x y z = 7 | Bar 8 | { x 9 | , y 10 | , z 11 | , .. 12 | } 13 | 14 | baz = Baz {..} 15 | -------------------------------------------------------------------------------- /data/examples/import/explicit-imports-out.hs: -------------------------------------------------------------------------------- 1 | import qualified MegaModule as M 2 | ( Either 3 | , Maybe (Just, Nothing) 4 | , MaybeT (..) 5 | , Monad (return, (>>), (>>=)) 6 | , MonadBaseControl 7 | , join 8 | , liftIO 9 | , void 10 | , (<<<) 11 | , (>>>) 12 | ) 13 | -------------------------------------------------------------------------------- /data/diff-tests/outputs/two-hunks.txt: -------------------------------------------------------------------------------- 1 | TEST 2 | @@ -1,7 +1,7 @@ 3 | module Main (main) where 4 | 5 | main :: IO () 6 | - main = return () 7 | + main = pure () 8 | 9 | foo :: Int 10 | foo = 11 | @@ -9,4 +9,4 @@ 12 | + 5 13 | 14 | bar :: Int 15 | - bar = 6 16 | + bar = 7 17 | -------------------------------------------------------------------------------- /data/examples/declaration/data/gadt/multiple-declaration.hs: -------------------------------------------------------------------------------- 1 | data GADT0 a where 2 | GADT01, GADT02 :: Int -> GADT0 a 3 | 4 | data GADT1 a where 5 | GADT11 6 | , GADT12 :: Int -> GADT1 a 7 | 8 | data GADT2 a where 9 | GADT21 10 | , GADT21 11 | , GADT22 :: Int -> GADT2 a 12 | -------------------------------------------------------------------------------- /data/examples/declaration/data/record-multi-const.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | 5 | data Foo = Foo 6 | { fooX :: Int -- ^ X 7 | , fooY :: Int -- ^ Y 8 | } | 9 | Bar 10 | { barX :: Int -- ^ X 11 | , barY :: Int -- ^ Y 12 | } 13 | deriving (Eq, Show) 14 | -------------------------------------------------------------------------------- /data/examples/declaration/splice/splice-decl.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | $( foo bar) 4 | 5 | $foo 6 | 7 | $$( foo bar) 8 | 9 | $$foo 10 | 11 | foo bar 12 | 13 | [|booya|] 14 | 15 | -- TemplateHaskell allows Q () at the top level 16 | do 17 | pure [] 18 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/infix/simple-out.hs: -------------------------------------------------------------------------------- 1 | (*) :: Int -> Int -> Int 2 | x * y = z 3 | 4 | foo :: Int -> Int -> Int 5 | x `foo` y = z 6 | 7 | bar :: Int -> Int -> Int -> Int 8 | (x `bar` y) z = z 9 | 10 | multiline :: Int -> Int -> Int 11 | x 12 | `multiline` y = z 13 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/overindentation-out.hs: -------------------------------------------------------------------------------- 1 | reallyincrediblyLongName = 2 | f 3 | a 4 | A 5 | { reallyincrediblyLongName = 6 | f 7 | a 8 | A 9 | { reallyincrediblyLongName 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /data/examples/import/simple.hs: -------------------------------------------------------------------------------- 1 | import Data.Text 2 | import Data.Text 3 | import qualified Data.Text as T 4 | import qualified Data.Text (a, c, b) 5 | import Data.Text (a, b, c) 6 | import Data.Text hiding (c, b, a) 7 | import Data.Text (a, b, c, b, a) 8 | import Data.Text hiding (c, b, a, b, c) 9 | -------------------------------------------------------------------------------- /data/examples/declaration/class/type-operators2-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiParamTypeClasses #-} 2 | {-# LANGUAGE TypeOperators #-} 3 | 4 | class a `Pair` b 5 | 6 | class 7 | a 8 | `Sum` b 9 | 10 | class (f `Product` g) a 11 | 12 | class 13 | ( f 14 | `Sum` g 15 | ) 16 | a 17 | -------------------------------------------------------------------------------- /data/examples/declaration/class/type-operators2.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiParamTypeClasses #-} 2 | {-# LANGUAGE TypeOperators #-} 3 | 4 | class 5 | a`Pair`b 6 | 7 | class 8 | a 9 | `Sum` b 10 | 11 | class (f`Product`g)a 12 | 13 | class ( 14 | f `Sum` g 15 | ) a 16 | 17 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/comprehension/transform-multi-line1-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TransformListComp #-} 2 | 3 | foo' xs ys = 4 | [ ( x 5 | , y 6 | ) 7 | | x <- xs 8 | , y <- ys 9 | , then 10 | -- First comment 11 | reverse -- Second comment 12 | ] 13 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/comprehension/transform-multi-line3.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TransformListComp #-} 2 | 3 | baz' xs ys = [ 4 | (x, 5 | y) | 6 | x <- xs, 7 | y <- ys, 8 | then 9 | group 10 | using -- First comment 11 | permutations -- Second comment 12 | ] 13 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/multiple-guards.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int 2 | foo x 3 | | x == 5 = 10 4 | | otherwise = 12 5 | 6 | bar :: Int -> Int 7 | bar x 8 | | x == 5 = foo x 9 | + foo 10 10 | | x == 6 = foo x 11 | + foo 20 12 | | otherwise = foo 100 13 | 14 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/where-nested-out.hs: -------------------------------------------------------------------------------- 1 | foo = bar 2 | where 3 | f1 = f1 4 | where 5 | f1 = 3 6 | f2 = f2 7 | where 8 | f2 = 3 9 | 10 | foo2 = bar 11 | where 12 | f1 = f1 where { f1 = 3; f1' = 4 }; f2 = f2 where f2 = 3; f2' = 4 13 | -------------------------------------------------------------------------------- /data/examples/module-header/stack-header-2-out.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env stack 2 | {- stack 3 | script 4 | --resolver lts-6.25 5 | --package turtle 6 | --package "stm async" 7 | --package http-client,http-conduit 8 | -} 9 | 10 | {-# LANGUAGE OverloadedStrings #-} 11 | 12 | main = return () 13 | -------------------------------------------------------------------------------- /data/examples/module-header/stack-header-2.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env stack 2 | {- stack 3 | script 4 | --resolver lts-6.25 5 | --package turtle 6 | --package "stm async" 7 | --package http-client,http-conduit 8 | -} 9 | 10 | {-# LANGUAGE OverloadedStrings #-} 11 | 12 | main = return () 13 | -------------------------------------------------------------------------------- /data/examples/declaration/class/type-operators3-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE PolyKinds #-} 2 | {-# LANGUAGE TypeFamilies #-} 3 | {-# LANGUAGE TypeOperators #-} 4 | {-# LANGUAGE NoStarIsType #-} 5 | 6 | class PNum x where 7 | type (a :: x) * (b :: x) 8 | 9 | instance PNum Nat where 10 | type a * b = () 11 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/associated-types-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TypeFamilies #-} 2 | 3 | instance Foo Int where type Bar Int = Double 4 | 5 | instance Foo Double where 6 | type 7 | Bar 8 | Double = 9 | [Double] 10 | 11 | type 12 | Baz Double = 13 | [Double] 14 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do/applications-and-parens.hs: -------------------------------------------------------------------------------- 1 | warningFor var place = do 2 | guard $ isVariableName var 3 | guard . not $ isInArray var place || isGuarded place 4 | (if includeGlobals || isLocal var 5 | then warningForLocals 6 | else warningForGlobals) var place 7 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/multi-way-if.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiWayIf #-} 2 | 3 | foo x = if | x == 5 -> 5 4 | 5 | bar x y = if 6 | | x > y -> x 7 | | x < y 8 | -> y 9 | | otherwise -> x 10 | 11 | baz = 12 | if | p -> f 13 | | otherwise -> g 14 | x 15 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/where-nested.hs: -------------------------------------------------------------------------------- 1 | foo = bar 2 | where 3 | f1 = f1 4 | where 5 | f1 = 3 6 | f2 = f2 7 | where 8 | f2 = 3 9 | 10 | foo2 = bar 11 | where 12 | { f1 = f1 where { f1 = 3; f1' = 4 }; f2 = f2 where { f2 = 3; f2' = 4 } } 13 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/arrow/proc-lets.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Arrows #-} 2 | 3 | foo f = proc a -> let b = a in f -< b 4 | 5 | bar f g = proc a -> 6 | let 7 | h 8 | = f 9 | . g a 10 | j = g 11 | . 12 | h 13 | in 14 | id -< (h, j) 15 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/complex-list.hs: -------------------------------------------------------------------------------- 1 | handleStuff = 2 | handle 3 | [ \ExceptionA -> 4 | something 5 | , \ExceptionB -> 6 | somethingElse 7 | ] 8 | 9 | handleStuff = 10 | handle 11 | [ foo 12 | bar 13 | , baz 14 | qux 15 | ] 16 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/multiple-guards-out.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int 2 | foo x 3 | | x == 5 = 10 4 | | otherwise = 12 5 | 6 | bar :: Int -> Int 7 | bar x 8 | | x == 5 = 9 | foo x 10 | + foo 10 11 | | x == 6 = 12 | foo x 13 | + foo 20 14 | | otherwise = foo 100 15 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/data-family-instances-gadt.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE GADTSyntax #-} 2 | {-# LANGUAGE TypeFamilies #-} 3 | data instance Bar Int a where 4 | SameBar 5 | :: Bar Int 6 | Int 7 | CloseBar :: Bar Int Double 8 | OtherBar 9 | :: Bar Int 10 | a 11 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/arrow/proc-ifs.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Arrows #-} 2 | 3 | foo f = proc a -> if a then f-<0 else f-<1 4 | 5 | bar f g = proc a -> 6 | if 7 | f a 8 | then 9 | f 10 | . g -< a 11 | else 12 | g 13 | -< 14 | b 15 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/complex-list-out.hs: -------------------------------------------------------------------------------- 1 | handleStuff = 2 | handle 3 | [ \ExceptionA -> 4 | something 5 | , \ExceptionB -> 6 | somethingElse 7 | ] 8 | 9 | handleStuff = 10 | handle 11 | [ foo 12 | bar 13 | , baz 14 | qux 15 | ] 16 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/guards.hs: -------------------------------------------------------------------------------- 1 | baz :: Int -> Int 2 | baz x | x < 0 = x 3 | baz x | otherwise = x 4 | 5 | multi_baz :: Int -> Int 6 | multi_baz x | x < 42 = x 7 | multi_baz x | x < 0 = x 8 | multi_baz x | otherwise = x 9 | 10 | quux :: Int -> Int 11 | quux x | x < 0 = x 12 | quux x = x 13 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/splice-pattern-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | singleLine = case () of 4 | $x -> () 5 | $(y "something") -> () 6 | 7 | multiline = case () of 8 | $( x 9 | + y 10 | ) -> () 11 | $( y 12 | "something" 13 | ) -> () 14 | -------------------------------------------------------------------------------- /region-tests/expected-result-9-12.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE LambdaCase #-} 2 | 3 | module Foo ( 4 | foo, bar, baz) where 5 | 6 | foo :: Int 7 | foo = 5 8 | 9 | bar :: Int -> Int 10 | bar = \case 11 | 0 -> foo 12 | x -> x - foo 13 | 14 | baz :: Int -> Int 15 | baz = gege 16 | where 17 | gege = 1 + 2 18 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/minimal/minimal-out.hs: -------------------------------------------------------------------------------- 1 | class Foo a where 2 | {-# MINIMAL (==) | ((/=), foo) #-} 3 | 4 | {-# MINIMAL 5 | a 6 | | ( b, c, d 7 | | e 8 | , f 9 | ) 10 | | g 11 | #-} 12 | 13 | (==) :: a -> a -> Bool 14 | (/=) :: a -> a -> Bool 15 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/awkward-comment-0-out.hs: -------------------------------------------------------------------------------- 1 | mergeErrorReply :: ParseError -> Reply s u a -> Reply s u a 2 | mergeErrorReply err1 reply -- XXX where to put it? 3 | = 4 | case reply of 5 | Ok x state err2 -> Ok x state (mergeError err1 err2) 6 | Error err2 -> Error (mergeError err1 err2) 7 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/comprehension/transform-multi-line2.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TransformListComp #-} 2 | 3 | bar' xs ys = [ 4 | (x, 5 | y) | 6 | x <- xs, 7 | y <- ys, 8 | then -- First comment 9 | sortWith 10 | by 11 | (x 12 | + y) -- Second comment 13 | ] 14 | 15 | 16 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/comprehension/transform-multi-line3-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TransformListComp #-} 2 | 3 | baz' xs ys = 4 | [ ( x 5 | , y 6 | ) 7 | | x <- xs 8 | , y <- ys 9 | , then group using 10 | -- First comment 11 | permutations -- Second comment 12 | ] 13 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do/applications-and-parens-out.hs: -------------------------------------------------------------------------------- 1 | warningFor var place = do 2 | guard $ isVariableName var 3 | guard . not $ isInArray var place || isGuarded place 4 | (if includeGlobals || isLocal var 5 | then warningForLocals 6 | else warningForGlobals) 7 | var 8 | place 9 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/guards-out.hs: -------------------------------------------------------------------------------- 1 | baz :: Int -> Int 2 | baz x | x < 0 = x 3 | baz x | otherwise = x 4 | 5 | multi_baz :: Int -> Int 6 | multi_baz x | x < 42 = x 7 | multi_baz x | x < 0 = x 8 | multi_baz x | otherwise = x 9 | 10 | quux :: Int -> Int 11 | quux x | x < 0 = x 12 | quux x = x 13 | -------------------------------------------------------------------------------- /data/examples/other/ascii.hs: -------------------------------------------------------------------------------- 1 | {- ----------------------------------- 2 | < What about ASCII art in comments? > 3 | ----------------------------------- 4 | \ ^__^ 5 | \ (oo)\_______ 6 | (__)\ )\/\ 7 | ||----w | 8 | || || 9 | -} 10 | -------------------------------------------------------------------------------- /region-tests/src.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE LambdaCase #-} 2 | 3 | module Foo ( 4 | foo, bar, baz) where 5 | 6 | foo :: Int 7 | foo = 5 8 | 9 | bar :: Int -> Int 10 | bar = \case 11 | 0 -> foo 12 | x -> x - foo 13 | 14 | baz :: Int -> Int 15 | baz = gege 16 | where 17 | gege = 1 + 2 18 | -------------------------------------------------------------------------------- /data/examples/declaration/data/gadt/record.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | 5 | data Foo where 6 | Foo :: { fooX :: Int } -> Foo 7 | Bar :: { fooY :: Int 8 | , fooBar, fooBaz :: Bool 9 | , fooFoo 10 | , barBar 11 | , bazBaz :: Int 12 | } -> Foo 13 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/contexts-comments.hs: -------------------------------------------------------------------------------- 1 | instance ( 2 | Read a, -- Foo 3 | Read b 4 | , Read ( 5 | c, -- Bar 6 | d 7 | ) 8 | ) 9 | => 10 | Read ( 11 | a, -- Baz 12 | b 13 | ,( 14 | c, -- Quux 15 | d 16 | ) 17 | ) where 18 | readsPrec = undefined 19 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/contexts.hs: -------------------------------------------------------------------------------- 1 | instance Eq a=>Eq [a] where (==) _ _ = False 2 | 3 | instance ( 4 | Ord a, 5 | Ord b 6 | ) => Ord (a,b) where 7 | compare _ _ = GT 8 | 9 | instance (Show a, Show b) => 10 | Show ( 11 | a, 12 | b 13 | ) where 14 | showsPrec _ _ = showString "" 15 | -------------------------------------------------------------------------------- /data/examples/declaration/rewrite-rule/basic1.hs: -------------------------------------------------------------------------------- 1 | {-# RULES 2 | "fold/build" foldr k z (build g) = g k z 3 | #-} 4 | 5 | {-# RULES 6 | "fusable/aux" 7 | fusable x (aux y) = faux x y 8 | #-} 9 | 10 | {-# RULES 11 | "map/map" 12 | map f 13 | (map g xs) = map 14 | (f . g) 15 | xs 16 | #-} 17 | 18 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/arrow/proc-ifs-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Arrows #-} 2 | 3 | foo f = proc a -> if a then f -< 0 else f -< 1 4 | 5 | bar f g = proc a -> 6 | if f a 7 | then 8 | f 9 | . g 10 | -< 11 | a 12 | else 13 | g 14 | -< 15 | b 16 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/awkward-comment-0.hs: -------------------------------------------------------------------------------- 1 | mergeErrorReply :: ParseError -> Reply s u a -> Reply s u a 2 | mergeErrorReply err1 reply -- XXX where to put it? 3 | = case reply of 4 | Ok x state err2 -> Ok x state (mergeError err1 err2) 5 | Error err2 -> Error (mergeError err1 err2) 6 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/static-pointers.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE StaticPointers #-} 2 | 3 | foo :: StaticPtr Int 4 | foo = static 5 5 | 6 | bar :: StaticPtr [Int] 7 | bar = static [ 1 8 | , 2, 3 9 | ] 10 | 11 | baz :: StaticPtr Bool 12 | baz = static (fun 1 13 | 2) 14 | -------------------------------------------------------------------------------- /data/examples/import/misc.hs: -------------------------------------------------------------------------------- 1 | import A hiding 2 | ( foobarbazqux 3 | , foobarbazqux 4 | , foobarbazqux 5 | , foobarbazqux 6 | , foobarbazqux 7 | , foobarbazqux 8 | , foobarbazqux 9 | ) 10 | 11 | import Name hiding () 12 | 13 | import {-# SOURCE #-} safe qualified Module as M hiding (a, b, c, d, e, f) 14 | -------------------------------------------------------------------------------- /data/examples/other/ascii-out.hs: -------------------------------------------------------------------------------- 1 | {- ----------------------------------- 2 | < What about ASCII art in comments? > 3 | ----------------------------------- 4 | \ ^__^ 5 | \ (oo)\_______ 6 | (__)\ )\/\ 7 | ||----w | 8 | || || 9 | -} 10 | -------------------------------------------------------------------------------- /data/examples/other/pragma-comments-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | -- TODO This extension is probably too dangerous, remove it. 3 | {-# LANGUAGE RecordWildCards #-} 4 | -- Avoid warning produced by TH. 5 | {-# OPTIONS_GHC -fno-warn-overlapping-patterns #-} 6 | 7 | -- | Header comment. 8 | module Foo () where 9 | -------------------------------------------------------------------------------- /region-tests/expected-result-6-8.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE LambdaCase #-} 2 | 3 | module Foo ( 4 | foo, bar, baz) where 5 | 6 | foo :: Int 7 | foo = 5 8 | bar :: Int -> Int 9 | bar = \case 10 | 0 -> foo 11 | x -> x - foo 12 | 13 | baz :: Int -> Int 14 | baz = gege 15 | where 16 | gege = 1 + 2 17 | -------------------------------------------------------------------------------- /data/examples/declaration/class/multi-parameters1-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiParamTypeClasses #-} 2 | 3 | class Foo a b where foo :: a -> b 4 | 5 | -- | Something. 6 | class Bar a b c d where 7 | bar 8 | :: a 9 | -> b 10 | -> c 11 | -> d 12 | 13 | class -- Before name 14 | Baz where 15 | baz :: Int 16 | -------------------------------------------------------------------------------- /data/examples/declaration/data/existential-multiline.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ExistentialQuantification #-} 2 | 3 | data Foo 4 | = forall a. MkFoo a (a -> Bool) 5 | | forall a. Eq a => MkBar a 6 | 7 | data Bar = forall x y. 8 | Bar x y x y 9 | 10 | data Baz = forall x y. 11 | Baz x y x 12 | y 13 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/instance-sigs-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE InstanceSigs #-} 2 | 3 | instance Eq Int where 4 | (==) :: Int -> Int -> Bool 5 | (==) _ _ = False 6 | 7 | instance Ord Int where 8 | compare 9 | :: Int 10 | -> Int 11 | -> Ordering 12 | compare 13 | _ 14 | _ = 15 | GT 16 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/multi-way-if-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiWayIf #-} 2 | 3 | foo x = if | x == 5 -> 5 4 | 5 | bar x y = 6 | if 7 | | x > y -> x 8 | | x < y -> 9 | y 10 | | otherwise -> x 11 | 12 | baz = 13 | if 14 | | p -> f 15 | | otherwise -> g 16 | x 17 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operator-comments-1-out.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | bar 3 | ++ 4 | -- some comment 5 | case foo of 6 | a -> a 7 | 8 | foo = 9 | bar 10 | ++ case foo of -- some comment 11 | a -> a 12 | 13 | foo = 14 | bar 15 | ++ case foo of -- some comment 16 | a -> a 17 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/type-applications.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TypeApplications #-} 2 | 3 | foo = f @String a b c 4 | 5 | bar = f @(Maybe Int) a b 6 | 7 | baz = f @Int @String 8 | a b 9 | 10 | goo = hash 11 | @(HASH TPraosStandardCrypto) 12 | @ByteString 13 | "And the lamb lies down on Broadway" 14 | -------------------------------------------------------------------------------- /data/examples/declaration/value/other/comments-get-before-op-out.hs: -------------------------------------------------------------------------------- 1 | main :: IO () 2 | main = do 3 | migrateSchema 4 | [ migration1 5 | , migration1 6 | , migration3 7 | -- When adding migrations here, don't forget to update 8 | -- 'schemaVersion' in Galley.Data 9 | ] 10 | `finally` Log.close 11 | -------------------------------------------------------------------------------- /region-tests/expected-result-6-7.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE LambdaCase #-} 2 | 3 | module Foo ( 4 | foo, bar, baz) where 5 | 6 | foo :: Int 7 | foo = 5 8 | 9 | bar :: Int -> Int 10 | bar = \case 11 | 0 -> foo 12 | x -> x - foo 13 | 14 | baz :: Int -> Int 15 | baz = gege 16 | where 17 | gege = 1 + 2 18 | -------------------------------------------------------------------------------- /data/examples/declaration/data/gadt/multiple-declaration-out.hs: -------------------------------------------------------------------------------- 1 | data GADT0 a where 2 | GADT01, GADT02 :: Int -> GADT0 a 3 | 4 | data GADT1 a where 5 | GADT11 6 | , GADT12 7 | :: Int 8 | -> GADT1 a 9 | 10 | data GADT2 a where 11 | GADT21 12 | , GADT21 13 | , GADT22 14 | :: Int 15 | -> GADT2 a 16 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/arithmetic-sequences.hs: -------------------------------------------------------------------------------- 1 | foo = [0..] 2 | foo' = [0..5] 3 | bar x = [ 4 | 0..x 5 | ] 6 | baz x = [ 7 | 1, 8 | 3 .. 9 | x 10 | ] 11 | barbaz x = [ 0, 1.. ] 12 | arst = [0 :: Int ..] 13 | brst = [0, 1 :: Int ..] 14 | crst = [0 :: Int .. 10] 15 | drst = [0, 1 :: Int .. 10] 16 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do/operator-and-parens-out.hs: -------------------------------------------------------------------------------- 1 | scientifically :: (Scientific -> a) -> Parser a 2 | scientifically h = do 3 | something 4 | (I.satisfy (\w -> w == 'e' || w == 'E') 5 | *> fmap (h . Sci.scientific signedCoeff . (e +)) (signed decimal)) 6 | <|> return (h $ Sci.scientific signedCoeff e) 7 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operator-comments-1.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | bar 3 | ++ 4 | -- some comment 5 | case foo of 6 | a -> a 7 | 8 | foo = 9 | bar 10 | ++ -- some comment 11 | case foo of 12 | a -> a 13 | 14 | foo = 15 | bar 16 | ++ case foo of -- some comment 17 | a -> a 18 | -------------------------------------------------------------------------------- /region-tests/expected-result-17-18.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE LambdaCase #-} 2 | 3 | module Foo ( 4 | foo, bar, baz) where 5 | 6 | foo :: Int 7 | foo = 5 8 | 9 | bar :: Int -> Int 10 | bar = \case 11 | 0 -> foo 12 | x -> x - foo 13 | 14 | baz :: Int -> Int 15 | baz = gege 16 | where 17 | gege = 1 + 2 18 | -------------------------------------------------------------------------------- /data/examples/declaration/data/gadt/record-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | data Foo where 5 | Foo :: {fooX :: Int} -> Foo 6 | Bar 7 | :: { fooY :: Int 8 | , fooBar, fooBaz :: Bool 9 | , fooFoo 10 | , barBar 11 | , bazBaz 12 | :: Int 13 | } -> 14 | Foo 15 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/associated-types.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TypeFamilies #-} 2 | 3 | instance Foo Int where type Bar Int = Double 4 | 5 | instance Foo Double 6 | where 7 | type 8 | Bar 9 | Double 10 | = 11 | [Double] 12 | 13 | 14 | type instance Baz Double 15 | = [Double] 16 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/data-family-instances-gadt-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE GADTSyntax #-} 2 | {-# LANGUAGE TypeFamilies #-} 3 | 4 | data instance Bar Int a where 5 | SameBar 6 | :: Bar 7 | Int 8 | Int 9 | CloseBar :: Bar Int Double 10 | OtherBar 11 | :: Bar 12 | Int 13 | a 14 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do/operator-and-parens.hs: -------------------------------------------------------------------------------- 1 | scientifically :: (Scientific -> a) -> Parser a 2 | scientifically h = do 3 | something 4 | ( I.satisfy (\w -> w == 'e' || w == 'E') 5 | *> fmap (h . Sci.scientific signedCoeff . (e +)) (signed decimal) 6 | ) 7 | <|> return (h $ Sci.scientific signedCoeff e) 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operator-comments-0-out.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | bar 3 | ++ 4 | {- some comment -} 5 | case foo of 6 | a -> a 7 | 8 | foo = 9 | bar 10 | ++ {- some comment -} case foo of 11 | a -> a 12 | 13 | foo = 14 | bar 15 | ++ case foo {- some comment -} of 16 | a -> a 17 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/view-pattern.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ViewPatterns #-} 2 | 3 | example f ( f -> 4 ) = True 4 | 5 | f (t -> Nothing) = "Nothing" 6 | f (t -> Just _) = "Just" 7 | 8 | g ((f, _), f -> 4) = True 9 | 10 | multiline (t -> Foo 11 | bar 12 | baz) = True 13 | -------------------------------------------------------------------------------- /data/examples/module-header/double-dot-with-names.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE PatternSynonyms #-} 2 | 3 | module ExportSyntax ( A(.., NoA), Q(F,..), G(T,..,U)) where 4 | 5 | data A = A | B 6 | 7 | pattern NoA = B 8 | 9 | data Q a = Q a 10 | 11 | pattern F a = Q a 12 | 13 | data G = G | H 14 | 15 | pattern T = G 16 | 17 | pattern U = H 18 | -------------------------------------------------------------------------------- /expected-failures/esqueleto.txt: -------------------------------------------------------------------------------- 1 | src/Database/Esqueleto/Internal/Internal.hs:384:1 2 | The GHC parser (in Haddock mode) failed: 3 | lexical error in string/character literal at character 's' 4 | test/PostgreSQL/Test.hs:564:9-41 5 | The GHC parser (in Haddock mode) failed: 6 | parse error on input `-- | Check the result is not null' 7 | -------------------------------------------------------------------------------- /region-tests/expected-result-all.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE LambdaCase #-} 2 | 3 | module Foo 4 | ( foo 5 | , bar 6 | , baz 7 | ) 8 | where 9 | 10 | foo :: Int 11 | foo = 5 12 | 13 | bar :: Int -> Int 14 | bar = \case 15 | 0 -> foo 16 | x -> x - foo 17 | 18 | baz :: Int -> Int 19 | baz = gege 20 | where 21 | gege = 1 + 2 22 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/comprehension/transform-multi-line2-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TransformListComp #-} 2 | 3 | bar' xs ys = 4 | [ ( x 5 | , y 6 | ) 7 | | x <- xs 8 | , y <- ys 9 | , then 10 | -- First comment 11 | sortWith 12 | by 13 | (x 14 | + y) -- Second comment 15 | ] 16 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/fancy-forall-0.hs: -------------------------------------------------------------------------------- 1 | wrapError :: forall outertag innertag t outer inner m a. 2 | ( forall x. Coercible (t m x) (m x) 3 | , forall m'. HasCatch outertag outer m' 4 | => HasCatch innertag inner (t m') 5 | , HasCatch outertag outer m ) 6 | => (forall m'. HasCatch innertag inner m' => m' a) -> m a 7 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/fancy-forall-1.hs: -------------------------------------------------------------------------------- 1 | magnify :: forall outertag innertag t outer inner m a. 2 | ( forall x. Coercible (t m x) (m x) 3 | , forall m'. HasReader outertag outer m' 4 | => HasReader innertag inner (t m') 5 | , HasReader outertag outer m ) 6 | => (forall m'. HasReader innertag inner m' => m' a) -> m a 7 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/operator-comments-0.hs: -------------------------------------------------------------------------------- 1 | foo = 2 | bar 3 | ++ 4 | {- some comment -} 5 | case foo of 6 | a -> a 7 | 8 | foo = 9 | bar 10 | ++ {- some comment -} 11 | case foo of 12 | a -> a 13 | 14 | foo = 15 | bar 16 | ++ case foo of {- some comment -} 17 | a -> a 18 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/view-pattern-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ViewPatterns #-} 2 | 3 | example f (f -> 4) = True 4 | 5 | f (t -> Nothing) = "Nothing" 6 | f (t -> Just _) = "Just" 7 | 8 | g ((f, _), f -> 4) = True 9 | 10 | multiline 11 | ( t -> 12 | Foo 13 | bar 14 | baz 15 | ) = True 16 | -------------------------------------------------------------------------------- /data/examples/other/cpp/lonely-hash.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import Data.Void 4 | import Test.Hspec 5 | import Test.Hspec.Megaparsec 6 | import Text.Megaparsec 7 | import Text.Megaparsec.Char 8 | 9 | # if !MIN_VERSION_base(4,13,0) 10 | import Data.Semigroup ((<>)) 11 | # endif 12 | 13 | main :: IO () 14 | main = return () 15 | -------------------------------------------------------------------------------- /data/examples/other/cpp/simple-import.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import Data.Void 4 | import Test.Hspec 5 | import Test.Hspec.Megaparsec 6 | import Text.Megaparsec 7 | import Text.Megaparsec.Char 8 | 9 | #if !MIN_VERSION_base(4,13,0) 10 | import Data.Semigroup ((<>)) 11 | #endif 12 | 13 | main :: IO () 14 | main = return () 15 | -------------------------------------------------------------------------------- /data/examples/other/merging-comments-out.hs: -------------------------------------------------------------------------------- 1 | foo xs = baz 2 | where 3 | bar = 4 | catMaybes 5 | [ lookup langKey gets -- 1 6 | , lookup langKey cookies -- 2 7 | , lookupText langKey session -- 3 8 | ] 9 | ++ xs -- 4 10 | 11 | -- Blah 12 | baz = addTwoLetters (id, Set.empty) bar 13 | -------------------------------------------------------------------------------- /data/examples/other/pragma-comments.hs: -------------------------------------------------------------------------------- 1 | -- | Header comment. 2 | 3 | {-# LANGUAGE OverloadedStrings #-} 4 | 5 | -- Avoid warning produced by TH. 6 | {-# OPTIONS_GHC -fno-warn-overlapping-patterns #-} 7 | 8 | -- TODO This extension is probably too dangerous, remove it. 9 | {-# LANGUAGE RecordWildCards #-} 10 | 11 | module Foo () where 12 | -------------------------------------------------------------------------------- /data/examples/declaration/class/associated-data2-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TypeFamilies #-} 2 | 3 | module Main where 4 | 5 | -- | Something more. 6 | class Baz a where 7 | -- | Baz bar 8 | data 9 | BazBar 10 | a 11 | b 12 | c 13 | 14 | -- | Baz baz 15 | data 16 | BazBaz 17 | b 18 | a 19 | c 20 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/contexts-comments-out.hs: -------------------------------------------------------------------------------- 1 | instance 2 | ( Read a -- Foo 3 | , Read b 4 | , Read 5 | ( c -- Bar 6 | , d 7 | ) 8 | ) 9 | => Read 10 | ( a -- Baz 11 | , b 12 | , ( c -- Quux 13 | , d 14 | ) 15 | ) 16 | where 17 | readsPrec = undefined 18 | -------------------------------------------------------------------------------- /data/examples/declaration/rewrite-rule/basic1-out.hs: -------------------------------------------------------------------------------- 1 | {-# RULES 2 | "fold/build" foldr k z (build g) = g k z 3 | #-} 4 | 5 | {-# RULES 6 | "fusable/aux" 7 | fusable x (aux y) = 8 | faux x y 9 | #-} 10 | 11 | {-# RULES 12 | "map/map" 13 | map 14 | f 15 | (map g xs) = 16 | map 17 | (f . g) 18 | xs 19 | #-} 20 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/set-cost-centre/set-cost-centre-out.hs: -------------------------------------------------------------------------------- 1 | f x y = g (x + y) 2 | where 3 | g z = z 4 | {-# SCC g #-} 5 | {-# SCC f #-} 6 | 7 | withString x y = x + y 8 | {-# SCC withString "cost_centre_name" #-} 9 | 10 | withString' x y = x + y 11 | {-# SCC 12 | withString' 13 | "cost_centre_name" 14 | #-} 15 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/awkward-comment-1.hs: -------------------------------------------------------------------------------- 1 | doForeign :: Vars -> [Name] -> [Term] -> Idris LExp 2 | doForeign x = x 3 | where 4 | splitArg tm | (_, [_,_,l,r]) <- unApply tm -- pair, two implicits 5 | = do let l' = toFDesc l 6 | r' <- irTerm (sMN 0 "__foreignCall") vs env r 7 | return (l', r') 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/infix/hanging.hs: -------------------------------------------------------------------------------- 1 | f = unFoo . foo bar baz 3 $ do 2 | act 3 | ret 4 | 5 | g = unFoo . foo 6 | bar 7 | baz 3 $ do 8 | act 9 | ret 10 | 11 | update = 12 | do 13 | foobar 14 | `catch` \case 15 | a -> a 16 | 17 | foo = bar ++ 18 | case foo of 19 | a -> a 20 | -------------------------------------------------------------------------------- /data/examples/module-header/double-dot-with-names-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE PatternSynonyms #-} 2 | 3 | module ExportSyntax (A (.., NoA), Q (F, ..), G (T, .., U)) where 4 | 5 | data A = A | B 6 | 7 | pattern NoA = B 8 | 9 | data Q a = Q a 10 | 11 | pattern F a = Q a 12 | 13 | data G = G | H 14 | 15 | pattern T = G 16 | 17 | pattern U = H 18 | -------------------------------------------------------------------------------- /data/examples/other/cpp/lonely-hash-out.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import Data.Void 4 | import Test.Hspec 5 | import Test.Hspec.Megaparsec 6 | import Text.Megaparsec 7 | import Text.Megaparsec.Char 8 | 9 | # if !MIN_VERSION_base(4,13,0) 10 | import Data.Semigroup ((<>)) 11 | # endif 12 | 13 | main :: IO () 14 | main = return () 15 | -------------------------------------------------------------------------------- /data/examples/other/cpp/simple-import-out.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import Data.Void 4 | import Test.Hspec 5 | import Test.Hspec.Megaparsec 6 | import Text.Megaparsec 7 | import Text.Megaparsec.Char 8 | 9 | #if !MIN_VERSION_base(4,13,0) 10 | import Data.Semigroup ((<>)) 11 | #endif 12 | 13 | main :: IO () 14 | main = return () 15 | -------------------------------------------------------------------------------- /data/examples/other/empty-forall.hs: -------------------------------------------------------------------------------- 1 | -- Empty foralls are handled correctly in different situations. 2 | 3 | data D = forall. D Int 4 | 5 | data G where 6 | G :: forall. Int -> G 7 | 8 | f :: forall. a -> a 9 | f x = x 10 | 11 | type family T x where 12 | forall. T x = x 13 | 14 | {-# RULES 15 | "r" 16 | forall. r a = () 17 | #-} 18 | -------------------------------------------------------------------------------- /data/examples/declaration/class/associated-data2.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | {-# LANGUAGE TypeFamilies #-} 4 | 5 | -- | Something more. 6 | class Baz a where 7 | -- | Baz bar 8 | data BazBar 9 | a 10 | b 11 | c 12 | 13 | -- | Baz baz 14 | data family BazBaz 15 | b 16 | a 17 | c 18 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/set-cost-centre/set-cost-centre.hs: -------------------------------------------------------------------------------- 1 | f x y = g (x + y) 2 | where 3 | g z = z 4 | {-# SCC g #-} 5 | 6 | {-# SCC f #-} 7 | 8 | withString x y = x + y 9 | 10 | {-# SCC withString "cost_centre_name" #-} 11 | 12 | withString' x y = x + y 13 | 14 | {-# SCC withString' 15 | "cost_centre_name" 16 | #-} 17 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/comprehension/transform-multi-line4.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TransformListComp #-} 2 | 3 | quux' xs ys = [ 4 | (x, 5 | y) | 6 | x <- xs, 7 | y <- ys, 8 | then 9 | group 10 | by -- First comment 11 | (x 12 | + y) 13 | using -- Second comment 14 | groupWith -- Third comment 15 | ] 16 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/static-pointers-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE StaticPointers #-} 2 | 3 | foo :: StaticPtr Int 4 | foo = static 5 5 | 6 | bar :: StaticPtr [Int] 7 | bar = 8 | static 9 | [ 1 10 | , 2 11 | , 3 12 | ] 13 | 14 | baz :: StaticPtr Bool 15 | baz = 16 | static 17 | (fun 18 | 1 19 | 2) 20 | -------------------------------------------------------------------------------- /data/examples/other/empty-forall-out.hs: -------------------------------------------------------------------------------- 1 | -- Empty foralls are handled correctly in different situations. 2 | 3 | data D = forall. D Int 4 | 5 | data G where 6 | G :: forall. Int -> G 7 | 8 | f :: forall. a -> a 9 | f x = x 10 | 11 | type family T x where 12 | forall. T x = x 13 | 14 | {-# RULES 15 | "r" 16 | r a = 17 | () 18 | #-} 19 | -------------------------------------------------------------------------------- /data/examples/declaration/class/type-operators1.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiParamTypeClasses #-} 2 | {-# LANGUAGE TypeOperators #-} 3 | 4 | class (:$) a b 5 | 6 | class (:&) 7 | a 8 | b 9 | 10 | class a:*b 11 | 12 | class 13 | a -- Before operator 14 | :+ 15 | b -- After operator 16 | 17 | class ( 18 | f :. g 19 | ) a 20 | -------------------------------------------------------------------------------- /data/examples/declaration/deriving/overlapping-out.hs: -------------------------------------------------------------------------------- 1 | deriving instance 2 | {-# OVERLAPPABLE #-} 3 | Ord 4 | Foo 5 | 6 | deriving instance 7 | {-# OVERLAPPING #-} 8 | Num 9 | Foo 10 | 11 | deriving instance 12 | {-# OVERLAPS #-} 13 | Read 14 | Foo 15 | 16 | deriving instance 17 | {-# INCOHERENT #-} 18 | Show 19 | Foo 20 | -------------------------------------------------------------------------------- /data/examples/declaration/deriving/overlapping.hs: -------------------------------------------------------------------------------- 1 | deriving instance 2 | {-# OVERLAPPABLE #-} 3 | Ord 4 | Foo 5 | deriving instance 6 | {-# OVERLAPPING #-} 7 | Num 8 | Foo 9 | deriving instance 10 | {-# OVERLAPS #-} 11 | Read 12 | Foo 13 | deriving instance 14 | {-# INCOHERENT #-} 15 | Show 16 | Foo 17 | 18 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/inline/inline-out.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int 2 | foo = id 3 | {-# INLINE foo #-} 4 | 5 | {-# INLINE [2] bar #-} 6 | bar :: Int -> Int 7 | bar = id 8 | 9 | baz :: Int -> Int 10 | baz = id 11 | {-# INLINE [~2] baz #-} 12 | 13 | reVector :: Bundle u a -> Bundle v a 14 | {-# INLINE reVector #-} 15 | reVector = M.reVector 16 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/pattern/multiline.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE PatternSynonyms #-} 2 | 3 | pattern Arrow :: Type 4 | -> Type -> Type 5 | 6 | pattern Foo, Bar :: 7 | Type -> Type -> Type 8 | 9 | pattern TypeSignature 10 | , FunctionBody 11 | , PatternSignature 12 | , WarningPragma :: [RdrName] 13 | -> HsDecl GhcPs 14 | -------------------------------------------------------------------------------- /data/examples/declaration/type/promotion-1.hs: -------------------------------------------------------------------------------- 1 | type S2 = Proxy ( '[ '[], '[] ]) 2 | type S4 = Proxy ( '( 'Just, ' T'T)) 3 | type S5 = Proxy ( '[ 'Just, ' TT'T]) 4 | type S6 = Proxy ( '( '(), '() )) 5 | type S7 = Proxy ( '( 'a, 'b )) 6 | type S8 = Proxy ( '[ Int, Bool ]) 7 | 8 | type E = TypeError ('Text "Some text") 9 | type G = '[ '( 'Just, 'Bool) ] 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/newline-single-line-body-out.hs: -------------------------------------------------------------------------------- 1 | function :: Int -> Int 2 | function a = 3 | aReallyLongFunctionNameThatShouldStayOnThisLineToAvoidOverflowing 10000 a 4 | 5 | function' :: String -> String 6 | function' s = case s of 7 | "ThisString" -> 8 | -- And a comment here is okay 9 | "Yay" 10 | _ -> "Boo" 11 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/newline-single-line-body.hs: -------------------------------------------------------------------------------- 1 | function :: Int -> Int 2 | function a = 3 | aReallyLongFunctionNameThatShouldStayOnThisLineToAvoidOverflowing 10000 a 4 | 5 | function' :: String -> String 6 | function' s = case s of 7 | "ThisString" -> -- And a comment here is okay 8 | "Yay" 9 | 10 | _ -> "Boo" 11 | -------------------------------------------------------------------------------- /data/examples/declaration/data/deriving-strategies.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | 5 | newtype Foo = Foo Int 6 | deriving stock (Eq, Show, Generic) 7 | deriving anyclass 8 | ( ToJSON 9 | , FromJSON 10 | ) 11 | deriving newtype (Num) 12 | deriving Monoid via (Sum Int) 13 | deriving Semigroup 14 | via (Sum Int) 15 | -------------------------------------------------------------------------------- /data/examples/declaration/data/existential-multiline-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ExistentialQuantification #-} 2 | 3 | data Foo 4 | = forall a. MkFoo a (a -> Bool) 5 | | forall a. Eq a => MkBar a 6 | 7 | data Bar 8 | = forall x y. 9 | Bar x y x y 10 | 11 | data Baz 12 | = forall x y. 13 | Baz 14 | x 15 | y 16 | x 17 | y 18 | -------------------------------------------------------------------------------- /data/examples/declaration/data/kind-annotations.hs: -------------------------------------------------------------------------------- 1 | data Something (n :: Nat) = Something 2 | 3 | data Format (k :: *) (k' :: *) (k'' :: *) 4 | 5 | type Parens1 = Proxy '(a :: A, b :: (B :: *)) 6 | type Parens2 = Proxy '((a :: A), (b :: B)) 7 | 8 | type family Foo a where 9 | Foo '(a :: Int, b :: Bool) = Int 10 | Foo '((a :: Int), (b :: Bool)) = Int 11 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/instance-sigs.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE InstanceSigs #-} 2 | 3 | instance Eq Int 4 | where 5 | (==) :: Int -> Int -> Bool 6 | (==) _ _ = False 7 | 8 | instance Ord Int where 9 | compare :: 10 | Int 11 | -> Int 12 | -> Ordering 13 | compare 14 | _ 15 | _ 16 | = GT 17 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/standalone-kind-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE StandaloneKindSignatures #-} 2 | 3 | type T 4 | :: (k -> Type) 5 | -> k 6 | -> Type 7 | data T m a = MkT (m a) (T Maybe (m a)) 8 | 9 | type C1 :: Type -> Constraint 10 | class C1 a 11 | 12 | type F :: Type -> Type 13 | type family F 14 | 15 | type G :: Type 16 | type G = a 17 | -------------------------------------------------------------------------------- /data/examples/declaration/type-synonyms/multi-line.hs: -------------------------------------------------------------------------------- 1 | type Foo a b c 2 | = Bar c a b 3 | 4 | type Foo 5 | a 6 | b c 7 | = Bar c a b 8 | 9 | type Foo = 10 | Bar 11 | Baz 12 | Quux 13 | 14 | type API 15 | = "route1" :> ApiRoute1 16 | :<|> "route2" :> ApiRoute2 -- comment here 17 | :<|> OmitDocs :> "i" :> ASomething API 18 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/arrow/recursive-procs.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Arrows #-} 2 | 3 | foo f g = proc (x, y) -> do 4 | rec 5 | a <- f y -< x 6 | b 7 | <- 8 | g x 9 | -< 10 | y 11 | bar -< ( 12 | a, 13 | b 14 | ) 15 | rec p <- f 16 | p -< a 17 | rec q <- g 18 | q-< b 19 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/lambda-single-line-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE BangPatterns #-} 2 | 3 | foo :: a -> a -> a 4 | foo x = \y -> x 5 | 6 | bar :: a -> a -> a 7 | bar x = 8 | \y -> x 9 | 10 | baz :: a -> a -> a 11 | baz = \ ~x ~y -> x 12 | 13 | zag :: a -> a -> a 14 | zag = \ !x !y -> x 15 | 16 | spl :: a -> a 17 | spl = \ $([p|x|]) -> x 18 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/lambda-single-line.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE BangPatterns #-} 2 | 3 | foo :: a -> a -> a 4 | foo x = \y -> x 5 | 6 | bar :: a -> a -> a 7 | bar x = 8 | \y -> x 9 | 10 | baz :: a -> a -> a 11 | baz = \ ~x ~y -> x 12 | 13 | zag :: a -> a -> a 14 | zag = \ !x !y -> x 15 | 16 | spl :: a -> a 17 | spl = \ $([p|x|]) -> x 18 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/type-applications-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TypeApplications #-} 2 | 3 | foo = f @String a b c 4 | 5 | bar = f @(Maybe Int) a b 6 | 7 | baz = 8 | f @Int @String 9 | a 10 | b 11 | 12 | goo = 13 | hash 14 | @(HASH TPraosStandardCrypto) 15 | @ByteString 16 | "And the lamb lies down on Broadway" 17 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/where-out.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int 2 | foo x = f x where f z = z 3 | 4 | bar :: Int -> Int 5 | bar x = f x 6 | where 7 | f :: Int -> Int 8 | f z = z 9 | 10 | baz :: Int -> Int 11 | baz x = q 12 | where 13 | y = x 14 | z = y 15 | q = z 16 | 17 | emptyWhere :: Int 18 | emptyWhere = 5 19 | where 20 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/where.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int 2 | foo x = f x where f z = z 3 | 4 | bar :: Int -> Int 5 | bar x = f x 6 | where 7 | f :: Int -> Int 8 | f z = z 9 | 10 | baz :: Int -> Int 11 | baz x = q 12 | where 13 | y = x 14 | z = y 15 | q = z 16 | 17 | emptyWhere :: Int 18 | emptyWhere = 5 19 | where 20 | -------------------------------------------------------------------------------- /data/examples/declaration/value/other/comments-get-before-op.hs: -------------------------------------------------------------------------------- 1 | main :: IO () 2 | main = do 3 | migrateSchema 4 | [ migration1 5 | , migration1 6 | , migration3 7 | -- When adding migrations here, don't forget to update 8 | -- 'schemaVersion' in Galley.Data 9 | ] 10 | `finally` 11 | Log.close 12 | -------------------------------------------------------------------------------- /data/examples/other/merging-comments.hs: -------------------------------------------------------------------------------- 1 | foo xs = baz 2 | where 3 | bar = catMaybes [ lookup langKey gets -- 1 4 | , lookup langKey cookies -- 2 5 | , lookupText langKey session -- 3 6 | ] ++ xs -- 4 7 | 8 | -- Blah 9 | baz = addTwoLetters (id, Set.empty) bar 10 | -------------------------------------------------------------------------------- /data/examples/other/pragma-sorting-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NondecreasingIndentation #-} 2 | {-# LANGUAGE ScopedTypeVariables #-} 3 | {-# LANGUAGE TypeFamilies #-} 4 | -- This gap is necessary for stylish Haskell not to re-arrange 5 | -- NoMonoLocalBinds before TypeFamilies 6 | {-# LANGUAGE NoMonoLocalBinds #-} 7 | 8 | module Foo 9 | ( bar 10 | ) 11 | where 12 | -------------------------------------------------------------------------------- /data/examples/declaration/class/multi-parameters1.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiParamTypeClasses #-} 2 | 3 | class Foo a b where foo :: a -> b 4 | 5 | -- | Something. 6 | class Bar a b c d 7 | where 8 | bar :: 9 | a 10 | -> b 11 | -> c 12 | -> d 13 | 14 | class -- Before name 15 | Baz 16 | where 17 | baz :: Int 18 | 19 | -------------------------------------------------------------------------------- /data/examples/declaration/class/type-operators1-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiParamTypeClasses #-} 2 | {-# LANGUAGE TypeOperators #-} 3 | 4 | class (:$) a b 5 | 6 | class 7 | (:&) 8 | a 9 | b 10 | 11 | class a :* b 12 | 13 | class 14 | a -- Before operator 15 | :+ b -- After operator 16 | 17 | class 18 | ( f 19 | :. g 20 | ) 21 | a 22 | -------------------------------------------------------------------------------- /data/examples/declaration/instance/contexts-out.hs: -------------------------------------------------------------------------------- 1 | instance Eq a => Eq [a] where (==) _ _ = False 2 | 3 | instance 4 | ( Ord a 5 | , Ord b 6 | ) 7 | => Ord (a, b) 8 | where 9 | compare _ _ = GT 10 | 11 | instance 12 | (Show a, Show b) 13 | => Show 14 | ( a 15 | , b 16 | ) 17 | where 18 | showsPrec _ _ = showString "" 19 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/type/arguments.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE RankNTypes #-} 2 | 3 | functionName 4 | :: (C1, C2, C3, C4, C5) 5 | => a 6 | -> b 7 | -> (forall a. 8 | (C6, C7) 9 | => LongDataTypeName 10 | -> a 11 | -> AnotherLongDataTypeName 12 | -> b 13 | -> c 14 | ) 15 | -> (c -> d) 16 | -> (a, b, c, d) 17 | -------------------------------------------------------------------------------- /data/examples/declaration/type-synonyms/multi-line-out.hs: -------------------------------------------------------------------------------- 1 | type Foo a b c = 2 | Bar c a b 3 | 4 | type Foo 5 | a 6 | b 7 | c = 8 | Bar c a b 9 | 10 | type Foo = 11 | Bar 12 | Baz 13 | Quux 14 | 15 | type API = 16 | "route1" :> ApiRoute1 17 | :<|> "route2" :> ApiRoute2 -- comment here 18 | :<|> OmitDocs :> "i" :> ASomething API 19 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/arrow/proc-applications.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Arrows #-} 2 | 3 | foo x = proc a -> a -< x 4 | 5 | bar f x = 6 | proc ( 7 | y, 8 | z, 9 | w 10 | ) -> f -- The value 11 | -< ( 12 | x, -- Foo 13 | w, -- Bar 14 | z -- Baz 15 | ) 16 | 17 | baz x = proc a -> a -<< x 18 | -------------------------------------------------------------------------------- /data/examples/other/pragma-sorting.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ScopedTypeVariables #-} 2 | {-# LANGUAGE TypeFamilies #-} 3 | {-# LANGUAGE NondecreasingIndentation #-} 4 | -- This gap is necessary for stylish Haskell not to re-arrange 5 | -- NoMonoLocalBinds before TypeFamilies 6 | {-# LANGUAGE NoMonoLocalBinds #-} 7 | 8 | module Foo ( 9 | bar 10 | ) where 11 | -------------------------------------------------------------------------------- /data/examples/declaration/annotation/annotation-out.hs: -------------------------------------------------------------------------------- 1 | {-# ANN module (5 :: Int) #-} 2 | 3 | {-# ANN 4 | module 5 | (5 6 | :: Int) 7 | #-} 8 | 9 | {-# ANN foo "hey" #-} 10 | foo :: Int 11 | foo = 5 12 | 13 | {-# ANN 14 | Char 15 | (Just 42) 16 | #-} 17 | 18 | data Foo = Foo Int 19 | {-# ANN type Foo ("HLint: ignore") #-} 20 | 21 | {- Comment -} 22 | -------------------------------------------------------------------------------- /data/examples/declaration/data/deriving-strategies-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | newtype Foo = Foo Int 5 | deriving stock (Eq, Show, Generic) 6 | deriving anyclass 7 | ( ToJSON 8 | , FromJSON 9 | ) 10 | deriving newtype (Num) 11 | deriving (Monoid) via (Sum Int) 12 | deriving 13 | (Semigroup) 14 | via (Sum Int) 15 | -------------------------------------------------------------------------------- /data/examples/declaration/data/kind-annotations-out.hs: -------------------------------------------------------------------------------- 1 | data Something (n :: Nat) = Something 2 | 3 | data Format (k :: *) (k' :: *) (k'' :: *) 4 | 5 | type Parens1 = Proxy '(a :: A, b :: (B :: *)) 6 | 7 | type Parens2 = Proxy '((a :: A), (b :: B)) 8 | 9 | type family Foo a where 10 | Foo '(a :: Int, b :: Bool) = Int 11 | Foo '((a :: Int), (b :: Bool)) = Int 12 | -------------------------------------------------------------------------------- /data/examples/declaration/data/record-multi-const-out.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | -- | Something. 4 | data Foo 5 | = Foo 6 | { -- | X 7 | fooX :: Int 8 | , -- | Y 9 | fooY :: Int 10 | } 11 | | Bar 12 | { -- | X 13 | barX :: Int 14 | , -- | Y 15 | barY :: Int 16 | } 17 | deriving (Eq, Show) 18 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/standalone-kind.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE StandaloneKindSignatures #-} 2 | 3 | type T :: (k -> Type) 4 | -> k 5 | -> Type 6 | 7 | data T m a = MkT (m a) (T Maybe (m a)) 8 | 9 | type C1 :: Type -> Constraint 10 | class C1 a 11 | 12 | type F :: Type -> Type 13 | type family F 14 | 15 | type G :: Type 16 | 17 | type G = a 18 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/awkward-comment-1-out.hs: -------------------------------------------------------------------------------- 1 | doForeign :: Vars -> [Name] -> [Term] -> Idris LExp 2 | doForeign x = x 3 | where 4 | splitArg tm | (_, [_, _, l, r]) <- unApply tm -- pair, two implicits 5 | = 6 | do 7 | let l' = toFDesc l 8 | r' <- irTerm (sMN 0 "__foreignCall") vs env r 9 | return (l', r') 10 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do/recursive-do-rec-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE RecursiveDo #-} 2 | 3 | foo = do 4 | rec a <- b + 5 5 | 6 | let d = c 7 | 8 | b <- a * 5 9 | 10 | something 11 | 12 | c <- a + b 13 | print c 14 | rec something $ do 15 | x <- a 16 | print x 17 | 18 | y <- c 19 | print y 20 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/list-notation-1-out.hs: -------------------------------------------------------------------------------- 1 | instance A.ToJSON UpdateTable where 2 | toJSON a = 3 | A.object $ 4 | "TableName" .= updateTableName a : 5 | "ProvisionedThroughput" .= updateProvisionedThroughput a : 6 | case updateGlobalSecondaryIndexUpdates a of 7 | [] -> [] 8 | l -> ["GlobalSecondaryIndexUpdates" .= l] 9 | -------------------------------------------------------------------------------- /data/examples/declaration/class/multi-parameters2-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiParamTypeClasses #-} 2 | 3 | module Main where 4 | 5 | -- | Something else. 6 | class 7 | BarBaz 8 | a -- Foo 9 | b -- Bar 10 | c -- Baz bar 11 | d -- Baz baz 12 | e -- Rest 13 | f 14 | where 15 | barbaz 16 | :: a -> f 17 | bazbar 18 | :: e 19 | -> f 20 | -------------------------------------------------------------------------------- /data/examples/declaration/rewrite-rule/type-signature.hs: -------------------------------------------------------------------------------- 1 | {-# RULES 2 | "fold/build" forall k z (g :: forall b. (a -> b -> b) -> b -> b). foldr k z (build g) = g k z 3 | #-} 4 | 5 | {-# RULES 6 | "fold/build" 7 | forall k z 8 | (g :: forall b. 9 | (a -> b -> b) -> b -> b). 10 | foldr k z (build g) = 11 | g k z 12 | #-} 13 | -------------------------------------------------------------------------------- /data/examples/declaration/signature/inline/inline.hs: -------------------------------------------------------------------------------- 1 | foo :: Int -> Int 2 | foo = id 3 | 4 | {-# INLINE foo #-} 5 | 6 | {-# INLINE [2] bar #-} 7 | 8 | bar :: Int -> Int 9 | bar = id 10 | 11 | baz :: Int -> Int 12 | baz = id 13 | {-# INLINE [~2] baz #-} 14 | 15 | reVector :: Bundle u a -> Bundle v a 16 | 17 | {-# INLINE reVector #-} 18 | reVector = M.reVector 19 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/do/recursive-do-rec.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE RecursiveDo #-} 2 | 3 | foo = do 4 | rec 5 | a <- b + 5 6 | 7 | let d = c 8 | 9 | b <- a * 5 10 | 11 | something 12 | 13 | c <- a + b 14 | print c 15 | rec something $ do 16 | x <- a 17 | print x 18 | 19 | y <- c 20 | print y 21 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/implicit-params.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ImplicitParams #-} 2 | sortBy :: (a -> a -> Bool) -> [a] -> [a] 3 | 4 | sortBy = undefined 5 | 6 | sort :: (?cmp :: a -> a -> Bool) => [a] -> [a] 7 | sort = sortBy ?cmp 8 | 9 | sort' :: (?cmp 10 | :: a -> a -> Bool 11 | ,?foo :: Int) => [a] -> [a] 12 | sort' = sort 13 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/infix/hanging-out.hs: -------------------------------------------------------------------------------- 1 | f = unFoo . foo bar baz 3 $ do 2 | act 3 | ret 4 | 5 | g = unFoo 6 | . foo 7 | bar 8 | baz 9 | 3 10 | $ do 11 | act 12 | ret 13 | 14 | update = 15 | do 16 | foobar 17 | `catch` \case 18 | a -> a 19 | 20 | foo = 21 | bar 22 | ++ case foo of 23 | a -> a 24 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/lambda-multi-line1.hs: -------------------------------------------------------------------------------- 1 | foo :: a -> a -> a 2 | foo x = \y -> 3 | x 4 | 5 | bar :: Int -> Int -> Int 6 | bar x = \y -> 7 | if x > y 8 | then 10 9 | else 12 10 | 11 | foo = 12 | prop "is inverse to closure" $ \(f :: StaticPtr (Int -> Int)) 13 | (x :: Int) -> 14 | (unclosure . closure) f x == deRefStaticPtr f x 15 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/list-notation-1.hs: -------------------------------------------------------------------------------- 1 | instance A.ToJSON UpdateTable where 2 | toJSON a = A.object 3 | $ "TableName" .= updateTableName a 4 | : "ProvisionedThroughput" .= updateProvisionedThroughput a 5 | : case updateGlobalSecondaryIndexUpdates a of 6 | [] -> [] 7 | l -> [ "GlobalSecondaryIndexUpdates" .= l ] 8 | -------------------------------------------------------------------------------- /data/examples/declaration/value/function/pattern/multiline-case-pattern.hs: -------------------------------------------------------------------------------- 1 | readerBench doc name = 2 | runPure $ case (getReader name, getWriter name) of 3 | (Right (TextReader r, rexts), 4 | Right (TextWriter w, wexts)) -> undefined 5 | 6 | f xs = case xs of 7 | [ a, 8 | b ] -> a + b 9 | 10 | g xs = case xs of 11 | (a: 12 | bs) -> a + b 13 | -------------------------------------------------------------------------------- /data/examples/declaration/class/associated-types2-out.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TypeFamilies #-} 2 | 3 | module Main where 4 | 5 | -- | Something more. 6 | class Baz a where 7 | -- | Baz bar 8 | type 9 | BazBar 10 | a -- Foo 11 | b -- Bar 12 | c 13 | 14 | -- | Baz baz 15 | type 16 | -- After type 17 | BazBaz 18 | b 19 | a 20 | c 21 | -------------------------------------------------------------------------------- /data/examples/declaration/foreign/foreign-export.hs: -------------------------------------------------------------------------------- 1 | foreign export ccall foo :: Int -> IO Int 2 | 3 | -- | 'foreignTomFun' is a very important thing 4 | foreign export ccall "tomography" foreignTomFun 5 | :: StablePtr Storage {- Storage is bad -} -> TomForegin 6 | 7 | foreign export {- We can't use capi here -} ccall "dynamic" 8 | export_nullaryMeth :: (IO HRESULT) -> IO (Ptr ()) 9 | --------------------------------------------------------------------------------