Skip to content

Language pragmas inside CPP blocks incorrectly modified #26

Closed
gregorycollins opened this Issue Dec 2, 2012 · 4 comments

2 participants

@gregorycollins

Consider the following code snippet:

{-# LANGUAGE CPP               #-}

#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy       #-}
#endif

Stylish-haskell will incorrectly move the Trustworthy pragma outside of the CPP block.

@jaspervdj
Owner

Couldn't reproduce it with the latest version/default settings, what version and settings are you using?

@gregorycollins

stylish-haskell-0.5.2.0, settings:

# stylish-haskell configuration file
# ==================================

# The stylish-haskell tool is mainly configured by specifying steps. These steps
# are a list, so they have an order, and one specific step may appear more than
# once (if needed). Each file is processed by these steps in the given order.
steps:
  # Convert some ASCII sequences to their Unicode equivalents. This is disabled
  # by default.
  # - unicode_syntax:
  #     # In order to make this work, we also need to insert the UnicodeSyntax
  #     # language pragma. If this flag is set to true, we insert it when it's
  #     # not already present. You may want to disable it if you configure
  #     # language extensions using some other method than pragmas. Default:
  #     # true.
  #     add_language_pragma: true

  # Import cleanup
  - imports:
      # There are different ways we can align names and lists.
      #
      # - global: Align the import names and import list throughout the entire
      #   file.
      #
      # - file: Like global, but don't add padding when there are no qualified
      #   imports in the file.
      #
      # - group: Only align the imports per group (a group is formed by adjacent
      #   import lines).
      #
      # - none: Do not perform any alignment.
      #
      # Default: global.
      align: global

  # Language pragmas
  - language_pragmas:
      # We can generate different styles of language pragma lists.
      #
      # - vertical: Vertical-spaced language pragmas, one per line.
      #
      # - compact: A more compact style.
      #
      # Default: vertical.
      style: vertical

      # stylish-haskell can detect redundancy of some language pragmas. If this
      # is set to true, it will remove those redundant pragmas. Default: true.
      remove_redundant: true

  # Align the types in record declarations
  - records: {}

  # Replace tabs by spaces. This is disabled by default.
  - tabs:
      # Number of spaces to use for each tab. Default: 8, as specified by the
      # Haskell report.
      spaces: 8

  # Remove trailing whitespace
  - trailing_whitespace: {}

# A common setting is the number of columns (parts of) code will be wrapped
# to. Different steps take this into account. Default: 80.
columns: 80

# Sometimes, language extensions are specified in a cabal file or from the
# command line instead of using language pragmas in the file. stylish-haskell
# needs to be aware of these, so it can parse the file correctly.
#
# No language extensions are enabled by default.
# language_extensions:
  # - TemplateHaskell
  # - QuasiQuotes
@jaspervdj jaspervdj added a commit that closed this issue Dec 5, 2012
@jaspervdj Deal with pragmas in groups
Closes #26
34cc01f
@jaspervdj jaspervdj closed this in 34cc01f Dec 5, 2012
@jaspervdj
Owner

This issue should no longer appear in stylish-haskell-0.5.5.0 which I just uploaded to hackage. Thanks for reporting!

@gregorycollins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.