Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Alignment with non-existing equal sign if let-expressions are used in function definitions with pattern matching #52

Open
stu204146-kiel opened this issue Aug 31, 2020 · 0 comments
Labels

Comments

@stu204146-kiel
Copy link

For example, consider the following module.

data ExampleData a b = FirstConstructor a | SecondConstructor [b]

mapExampleData :: (a -> c) -> (b -> d) -> ExampleData a b -> ExampleData c d
mapExampleData f g (SecondConstructor ys) = let ys' = map g ys in SecondConstructor ys'
mapExampleData f g (FirstConstructor x) = FirstConstructor (f x)

After formatting it using Floskell, the equal sign of the second rule is aligned to a non-existing equal sign.

data ExampleData a b = FirstConstructor a | SecondConstructor [b]

mapExampleData :: (a -> c) -> (b -> d) -> ExampleData a b -> ExampleData c d
mapExampleData f g (SecondConstructor ys)
  = let ys' = map g ys in SecondConstructor ys'
mapExampleData f g (FirstConstructor x)   = FirstConstructor (f x)

The following configuration file was used.

{
  "style": "base",
  "language": "Haskell2010",
  "extensions": [
    "DataKinds",
    "FlexibleContexts",
    "GADTs",
    "PolyKinds",
    "TypeOperators"
  ],
  "fixities": [
    "infixr 5 </>",
    "infixr 7 <.>",
    "infix 5 \\\\"
  ],
  "formatting": {
    "penalties": {
      "indent": 1,
      "linebreak": 100,
      "max-line-length": 80,
      "overfull": 100,
      "overfull-once": 1000
    },
    "layout": {
      "export-spec-list": "try-oneline",
      "import-spec-list": "flex",
      "app": "flex",
      "infix-app": "try-oneline",
      "declaration": "flex",
      "con-decls": "try-oneline",
      "if": "try-oneline",
      "let": "try-oneline",
      "list-comp": "try-oneline",
      "record": "try-oneline",
      "type": "try-oneline"
    },
    "indent": {
      "class": "indent-by 2",
      "case": "indent-by 2",
      "do": "indent-by 2",
      "export-spec-list": "indent-by 2",
      "import-spec-list": "indent-by 2",
      "let": "align",
      "let-in": "align",
      "let-binds": "align",
      "if": "indent-by 2",
      "multi-if": "align-or-indent-by 2",
      "deriving": 1,
      "where": 1,
      "where-binds": "indent-by 1",
      "typesig": "align",
      "app": "indent-by 2",
      "onside": 2
    },
    "align": {
      "case": true,
      "class": true,
      "import-module": true,
      "import-spec": true,
      "let-binds": true,
      "matches": true,
      "record-fields": true,
      "where": true,
      "limits": [
        20,
        25
      ]
    },
    "group": {
      "default": {
        "force-linebreak": false,
        "spaces": "both",
        "linebreaks": "after"
      },
      "(": {
        "force-linebreak": false,
        "spaces": "none",
        "linebreaks": "after"
      },
      "( in other": {
        "force-linebreak": false,
        "spaces": "both",
        "linebreaks": "after"
      },
      "[": {
        "force-linebreak": false,
        "spaces": "none",
        "linebreaks": "after"
      },
      "[ in type": {
        "force-linebreak": false,
        "spaces": "none",
        "linebreaks": "after"
      }
    },
    "op": {
      "default": {
        "force-linebreak": false,
        "spaces": "both",
        "linebreaks": "before"
      },
      ",": {
        "force-linebreak": false,
        "spaces": "after",
        "linebreaks": "before"
      },
      "-> in expression": {
        "force-linebreak": false,
        "spaces": "both",
        "linebreaks": "after"
      }
    },
    "options": {
      "align-sum-type-decl": true,
      "decl-no-blank-lines": [],
      "flexible-oneline": true,
      "preserve-vertical-space": false,
      "sort-import-lists": true,
      "sort-pragmas": true,
      "split-language-pragmas": true,
      "sort-imports": [
        {
          "prefixes": [
            "Prelude"
          ],
          "order": "sorted"
        },
        {
          "prefixes": [
            ""
          ],
          "order": "sorted"
        },
        {
          "prefixes": [
            "HST"
          ],
          "order": "sorted"
        }
      ]
    }
  }
}
@ennocramer ennocramer added the bug label Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants