createChecks :: Style -> [Check]
createChecks style
  = concat
      [[lineLengthLimitCheck, ribbonsPerLineCheck,
        successiveEmptyLinesLimitCheck],
       indentationChecks, [onsideLessCheck]]
  where lineLengthLimitCheck
          = createCheck (rawLineLengthLimit > 0)
              ["The line length limit must be positive, but it is ",
               show rawLineLengthLimit, "."]
        rawLineLengthLimit = lineLengthLimit style
        ribbonsPerLineCheck
          = createCheck (rawRibbonsPerLine >= 1)
              ["The ribbons per line ratio must be at least 1, but it is ",
               show rawRibbonsPerLine, "."]
        rawRibbonsPerLine = ribbonsPerLine style
        successiveEmptyLinesLimitCheck
          = createCheck (rawSuccessiveEmptyLinesLimit >= 0)
              ["The successive empty lines limit must not be negative, ",
               "but it is ", show rawSuccessiveEmptyLinesLimit, "."]
        rawSuccessiveEmptyLinesLimit = successiveEmptyLinesLimit style

        indentationChecks = fmap checkIndentation indentations
        checkIndentation (indentation, name)
          = createCheck (indentation > 0)
              ["The ", name, " indentation must be positive, but it is ",
               show indentation, "."]
        indentations
          = [(rawClassIndentation, "class"), (rawDoIndentation, "do"),
             (rawCaseIndentation, "case"), (rawLetIndentation, "let"),
             (rawWhereIndentation, "where"), (rawOnsideIndentation, onsideName)]
        rawClassIndentation = classIndentation style
        rawDoIndentation = doIndentation style
        rawCaseIndentation = caseIndentation style
        rawLetIndentation = letIndentation style
        rawWhereIndentation = whereIndentation style
        rawOnsideIndentation = onsideIndentation style
        onsideName = "onside"
        onsideLessCheck
          = createCheck
              (and $ fmap (> rawOnsideIndentation) greaterOnsideIndentations)
              ["The ", onsideName,
               " indentation must be less than the other indentations, ",
               "but it is ", show rawOnsideIndentation, "."]
        greaterOnsideIndentations
          = [rawClassIndentation, rawDoIndentation, rawCaseIndentation,
             rawLetIndentation, rawWhereIndentation]
createChecks :: Style -> [Check]
createChecks style
  = concat
      [[lineLengthLimitCheck, ribbonsPerLineCheck,
        successiveEmptyLinesLimitCheck],
       indentationChecks, [onsideLessCheck]]
  where lineLengthLimitCheck
          = createCheck (rawLineLengthLimit > 0)
              ["The line length limit must be positive, but it is ",
               show rawLineLengthLimit, "."]
        rawLineLengthLimit = lineLengthLimit style
        ribbonsPerLineCheck
          = createCheck (rawRibbonsPerLine >= 1)
              ["The ribbons per line ratio must be at least 1, but it is ",
               show rawRibbonsPerLine, "."]
        rawRibbonsPerLine = ribbonsPerLine style
        successiveEmptyLinesLimitCheck
          = createCheck (rawSuccessiveEmptyLinesLimit >= 0)
              ["The successive empty lines limit must not be negative, ",
               "but it is ", show rawSuccessiveEmptyLinesLimit, "."]
        rawSuccessiveEmptyLinesLimit = successiveEmptyLinesLimit style

        indentationChecks = fmap checkIndentation indentations
        checkIndentation (indentation, name)
          = createCheck (indentation > 0)
              ["The ", name, " indentation must be positive, but it is ",
               show indentation, "."]
        indentations
          = [(rawClassIndentation, "class"), (rawDoIndentation, "do"),
             (rawCaseIndentation, "case"), (rawLetIndentation, "let"),
             (rawWhereIndentation, "where"), (rawOnsideIndentation, onsideName)]
        rawClassIndentation = classIndentation style
        rawDoIndentation = doIndentation style
        rawCaseIndentation = caseIndentation style
        rawLetIndentation = letIndentation style
        rawWhereIndentation = whereIndentation style
        rawOnsideIndentation = onsideIndentation style
        onsideName = "onside"
        onsideLessCheck
          = createCheck
              (and $ fmap (> rawOnsideIndentation) greaterOnsideIndentations)
              ["The ", onsideName,
               " indentation must be less than the other indentations, ",
               "but it is ", show rawOnsideIndentation, "."]
        greaterOnsideIndentations
          = [rawClassIndentation, rawDoIndentation, rawCaseIndentation,
             rawLetIndentation, rawWhereIndentation]
createChecks style
  = concat
      [[lineLengthLimitCheck, ribbonsPerLineCheck,
        successiveEmptyLinesLimitCheck],
       indentationChecks, [onsideLessCheck]]
  where lineLengthLimitCheck
          = createCheck (rawLineLengthLimit > 0)
              ["The line length limit must be positive, but it is ",
               show rawLineLengthLimit, "."]
        rawLineLengthLimit = lineLengthLimit style
        ribbonsPerLineCheck
          = createCheck (rawRibbonsPerLine >= 1)
              ["The ribbons per line ratio must be at least 1, but it is ",
               show rawRibbonsPerLine, "."]
        rawRibbonsPerLine = ribbonsPerLine style
        successiveEmptyLinesLimitCheck
          = createCheck (rawSuccessiveEmptyLinesLimit >= 0)
              ["The successive empty lines limit must not be negative, ",
               "but it is ", show rawSuccessiveEmptyLinesLimit, "."]
        rawSuccessiveEmptyLinesLimit = successiveEmptyLinesLimit style

        indentationChecks = fmap checkIndentation indentations
        checkIndentation (indentation, name)
          = createCheck (indentation > 0)
              ["The ", name, " indentation must be positive, but it is ",
               show indentation, "."]
        indentations
          = [(rawClassIndentation, "class"), (rawDoIndentation, "do"),
             (rawCaseIndentation, "case"), (rawLetIndentation, "let"),
             (rawWhereIndentation, "where"), (rawOnsideIndentation, onsideName)]
        rawClassIndentation = classIndentation style
        rawDoIndentation = doIndentation style
        rawCaseIndentation = caseIndentation style
        rawLetIndentation = letIndentation style
        rawWhereIndentation = whereIndentation style
        rawOnsideIndentation = onsideIndentation style
        onsideName = "onside"
        onsideLessCheck
          = createCheck
              (and $ fmap (> rawOnsideIndentation) greaterOnsideIndentations)
              ["The ", onsideName,
               " indentation must be less than the other indentations, ",
               "but it is ", show rawOnsideIndentation, "."]
        greaterOnsideIndentations
          = [rawClassIndentation, rawDoIndentation, rawCaseIndentation,
             rawLetIndentation, rawWhereIndentation]