Skip to content

Commit

Permalink
Add tested-with, fix compilation with older ghcs
Browse files Browse the repository at this point in the history
  • Loading branch information
jhrcek committed Jun 30, 2024
1 parent 6144eac commit 0f2ad70
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cabal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
ghc: ["9.4", "9.6", "9.8", "9.10"]
ghc: ["9.6", "9.8", "9.10"]
fail-fast: false

steps:
Expand Down
11 changes: 5 additions & 6 deletions lib/Language/Haskell/Stylish/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ module Language.Haskell.Stylish.Parse

--------------------------------------------------------------------------------
import Data.Char (toLower)
import Data.List (foldl',
stripPrefix)
import Data.List (stripPrefix)
import Data.Maybe (catMaybes,
fromMaybe,
listToMaybe,
Expand All @@ -25,7 +24,7 @@ import qualified GHC.Types.SrcLoc as GHC
import qualified GHC.Utils.Error as GHC
import qualified Language.Haskell.GhclibParserEx.GHC.Driver.Session as GHCEx
import qualified Language.Haskell.GhclibParserEx.GHC.Parser as GHCEx

import qualified Data.List as List

--------------------------------------------------------------------------------
import Language.Haskell.Stylish.GHC
Expand Down Expand Up @@ -91,7 +90,7 @@ parseModule externalExts0 fp string = do
ExtensionOk x onOff -> pure $ Just (x, onOff)

-- Build first dynflags.
let dynFlags0 = foldl' toggleExt baseDynFlags externalExts1
let dynFlags0 = List.foldl' toggleExt baseDynFlags externalExts1

-- Parse options from file
let fileOptions = fmap GHC.unLoc $ snd $ GHC.getOptions (GHC.initParserOpts dynFlags0)
Expand All @@ -105,7 +104,7 @@ parseModule externalExts0 fp string = do
fileOptions

-- Set further dynflags.
let dynFlags1 = foldl' toggleExt dynFlags0 fileExtensions
let dynFlags1 = List.foldl' toggleExt dynFlags0 fileExtensions
`GHC.gopt_set` GHC.Opt_KeepRawTokenStream

-- Possibly strip CPP.
Expand All @@ -120,7 +119,7 @@ parseModule externalExts0 fp string = do
where
withFileName x = maybe "" (<> ": ") fp <> x

toggleExt dynFlags (ext, onOff) = foldl'
toggleExt dynFlags (ext, onOff) = List.foldl'
toggleExt
((if onOff then GHC.xopt_set else GHC.xopt_unset) dynFlags ext)
[(rhs, onOff') | (lhs, onOff', rhs) <- GHC.impliedXFlags, lhs == ext]
4 changes: 2 additions & 2 deletions lib/Language/Haskell/Stylish/Step/SimpleAlign.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Data.Maybe (fromMaybe)
import qualified GHC.Hs as Hs
import qualified GHC.Parser.Annotation as GHC
import qualified GHC.Types.SrcLoc as GHC

import qualified Data.List as List

--------------------------------------------------------------------------------
import Language.Haskell.Stylish.Align
Expand Down Expand Up @@ -117,7 +117,7 @@ matchToAlignable (GHC.L matchLoc m@(Hs.Match _ Hs.CaseAlt pats@(_ : _) grhss)) =
pat = last patsLocs
guards = getGuards m
guardsLocs = map GHC.getLocA guards
left = foldl' GHC.combineSrcSpans pat guardsLocs
left = List.foldl' GHC.combineSrcSpans pat guardsLocs
body <- rhsBody grhss
matchPos <- GHC.srcSpanToRealSrcSpan $ GHC.locA matchLoc
leftPos <- GHC.srcSpanToRealSrcSpan left
Expand Down
1 change: 1 addition & 0 deletions stylish-haskell.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Maintainer: Jasper Van der Jeugt <[email protected]>
Copyright: 2012 Jasper Van der Jeugt
Category: Language
Build-type: Simple
Tested-with: GHC == 9.6.5 || == 9.8.2 || == 9.10.1

Description:
A Haskell code prettifier. For more information, see:
Expand Down

0 comments on commit 0f2ad70

Please sign in to comment.