ennocramer / floskell

Floskell is a flexible Haskell source code pretty printer.
BSD 3-Clause "New" or "Revised" License
178 stars 22 forks source link

Module header is longer than specified in configuration #51

Closed stu204146-kiel closed 3 years ago

stu204146-kiel commented 4 years ago

For example, consider the following module.

module SimpleFunctions ( identity, compose, append, firstElement, secondElem ) where

identity :: a -> a
identity x = x

compose :: (b -> c) -> (a -> b) -> a -> c
compose g f x = g (f x)

append :: [a] -> [a] -> [a]
append [] ys = ys
append (x:xs) ys = x : (append xs ys)

firstElement :: (a,b) -> a
firstElement (x,_) = x

secondElem :: (a,b) -> b
secondElem (_,y) = y

Here, the header line is 84 characters long.

After formatting the module with Floskell, the module header is still 84 characters long, although I have set the maximum line characters to 80.

module SimpleFunctions ( identity, compose, append, firstElement, secondElem ) where

identity :: a -> a
identity x = x

compose :: (b -> c) -> (a -> b) -> a -> c
compose g f x = g (f x)

append :: [a] -> [a] -> [a]
append [] ys       = ys
append (x : xs) ys = x : (append xs ys)

firstElement :: (a, b) -> a
firstElement (x, _) = x

secondElem :: (a, b) -> b
secondElem (_, y) = y

Here, the module header is still 84 characters long.

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 commented 3 years ago

Thank you for the report. This behavior is now fixed in master, as of commit 7989c67.