Skip to content

Commit

Permalink
Eliminate the fixity-th cabal flag
Browse files Browse the repository at this point in the history
The flag caused problems on GHC 9.4 and generally was a magnet for bugs, see
#941 and
#927. We are going to try to use
file-embed unconditionally and make parsing more efficient instead.
  • Loading branch information
mrkkrp committed Jan 3, 2023
1 parent 372bd0c commit 374773a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 29 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Ormolu 0.5.2.0

* Eliminated the `fixity-th` Cabal flag because it caused issues on GHC
9.4.1. See [issue 941](https://github.com/tweag/ormolu/issues/941) and
[issue 927](https://github.com/tweag/ormolu/issues/927).

## Ormolu 0.5.1.0

* Imports are now sorted by package qualifier, if one is present.
Expand Down
1 change: 0 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ let
({ pkgs, lib, ... }: lib.mkIf pkgs.stdenv.hostPlatform.isGhcjs {
reinstallableLibGhc = false;
packages.ormolu = {
flags.fixity-th = false;
writeHieFiles = lib.mkForce false;
};
packages.ormolu-live.ghcOptions =
Expand Down
11 changes: 1 addition & 10 deletions ormolu.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ flag dev
default: False
manual: True

flag fixity-th
description: Parse the default fixity information via Template Haskell
manual: True

library
exposed-modules:
Ormolu
Expand Down Expand Up @@ -104,6 +100,7 @@ library
directory ^>=1.3,
dlist >=0.8 && <2.0,
exceptions >=0.6 && <0.11,
file-embed >=0.0.15 && <0.1,
filepath >=1.2 && <1.5,
ghc-lib-parser >=9.4 && <9.5,
megaparsec >=9.0,
Expand All @@ -115,12 +112,6 @@ library

mixins: ghc-lib-parser hiding (Language.Haskell.TH.Syntax)

if (flag(fixity-th) && impl(ghc <9.4))
cpp-options: -DFIXITY_TH

else
build-depends: file-embed >=0.0.15 && <0.1

if flag(dev)
ghc-options:
-Wall -Werror -Wcompat -Wincomplete-record-updates
Expand Down
20 changes: 2 additions & 18 deletions src/Ormolu/Fixity.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE TemplateHaskell #-}
Expand All @@ -22,38 +21,23 @@ module Ormolu.Fixity
where

import qualified Data.Aeson as A
import Data.FileEmbed (embedFile)
import Data.Foldable (foldl')
import Data.List.NonEmpty (NonEmpty ((:|)))
import qualified Data.List.NonEmpty as NE
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.Maybe (fromMaybe)
import Data.Maybe (fromJust, fromMaybe)
import Data.MemoTrie (HasTrie, memo)
import Data.Semigroup (sconcat)
import Data.Set (Set)
import qualified Data.Set as Set
import Ormolu.Fixity.Internal
#if FIXITY_TH
import Control.Monad.IO.Class (MonadIO (liftIO))
import qualified Language.Haskell.TH.Syntax as TH
#else
import Data.FileEmbed (embedFile)
import Data.Maybe (fromJust)
#endif

packageToOps :: Map String FixityMap
packageToPopularity :: Map String Int
#if FIXITY_TH
HackageInfo packageToOps packageToPopularity =
$( do
let path = "extract-hackage-info/hackage-info.json"
info <- liftIO $ either fail pure =<< A.eitherDecodeFileStrict' path
TH.lift (info :: HackageInfo)
)
#else
HackageInfo packageToOps packageToPopularity =
fromJust $ A.decodeStrict $(embedFile "extract-hackage-info/hackage-info.json")
#endif

-- | List of packages shipped with GHC, for which the download count from
-- Hackage does not reflect their high popularity.
Expand Down

0 comments on commit 374773a

Please sign in to comment.