From 1676314fc3033e2077fc15d8513472898c9d9768 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Thu, 10 Jul 2025 12:30:02 +0200 Subject: [PATCH] nix: build with GHC 9.12.3 Jumping past GHC 9.6, 9.8 and 9.10 immediately, because these versions do not successfully build the static binary with TemplateHaskell and iserv-proxy, yet. Michal wrote the changes to hsie. Co-authored-by: Michal Kleczek --- default.nix | 2 +- nix/hsie/Main.hs | 27 ++++++++++++++++++++------- postgrest.cabal | 3 +-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/default.nix b/default.nix index c28e1cf2b..f19279232 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,6 @@ { system ? builtins.currentSystem -, compiler ? "ghc948" +, compiler ? "ghc9123" , # Commit of the Nixpkgs repository that we want to use. # It defaults to reading the inputs from flake.lock, which serves diff --git a/nix/hsie/Main.hs b/nix/hsie/Main.hs index ed8543053..7b2efa406 100644 --- a/nix/hsie/Main.hs +++ b/nix/hsie/Main.hs @@ -4,6 +4,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TupleSections #-} +{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} -- | Haskell Imports and Exports tool @@ -33,13 +34,16 @@ import Data.Function ((&)) import Data.List (intercalate) import Data.Maybe (catMaybes, mapMaybe) import Data.Text (Text) +import GHC.Driver.Errors.Types (GhcMessage) import GHC.Generics (Generic) import GHC.Hs.Extension (GhcPs) -import GHC.Types.Error (getMessages) +import GHC.Types.Error (Messages, defaultDiagnosticOpts, + getMessages) import GHC.Types.Name.Occurrence (occNameString) import GHC.Types.Name.Reader (rdrNameOcc) -import GHC.Unit.Module.Name (moduleNameString) +import GHC.Unit.Module (moduleNameString) import GHC.Utils.Error (pprMsgEnvelopeBagWithLoc) +import GHC.Utils.Outputable (showSDocUnsafe) import System.Directory.Recursive (getFilesRecursive) import System.Exit (exitFailure) @@ -198,7 +202,7 @@ sourceSymbols source = do return $ concatMap (importSymbols source filepath . GHC.unLoc) hsmodImports -- | Parse a Haskell module -parseModule :: FilePath -> IO GHC.HsModule +parseModule :: FilePath -> IO (GHC.HsModule GhcPs) parseModule filepath = do result <- ExactPrint.parseModule GHC.Paths.libdir filepath case result of @@ -206,7 +210,13 @@ parseModule filepath = do return $ GHC.unLoc hsmod Left errs -> fail $ "Errors with " <> show filepath <> ":\n " - <> show (pprMsgEnvelopeBagWithLoc $ getMessages errs) + <> formatParseErrors errs + +formatParseErrors :: Messages GhcMessage -> String +formatParseErrors errs = + intercalate "\n " + . fmap showSDocUnsafe + $ pprMsgEnvelopeBagWithLoc (defaultDiagnosticOpts @GhcMessage) (getMessages errs) -- | Symbols imported in an import declaration. -- @@ -214,9 +224,12 @@ parseModule filepath = do -- only one item is returned. importSymbols :: FilePath -> FilePath -> GHC.ImportDecl GhcPs -> [ImportedSymbol] importSymbols source filepath GHC.ImportDecl{..} = - case ideclHiding of - Just (hiding, syms) -> - symbol (if hiding then Hiding else Explicit) . Just . GHC.unLoc <$> GHC.unLoc syms + case ideclImportList of + Just (importListInterpretation, syms) -> + symbol (if importListInterpretation == GHC.EverythingBut then Hiding else Explicit) + . Just + . GHC.unLoc + <$> GHC.unLoc syms Nothing -> [ symbol Wildcard Nothing ] where diff --git a/postgrest.cabal b/postgrest.cabal index f9f656ff9..db78b9fd3 100644 --- a/postgrest.cabal +++ b/postgrest.cabal @@ -16,8 +16,6 @@ build-type: Simple extra-source-files: CHANGELOG.md tested-with: - -- nix - GHC == 9.4.8 -- cabal on Ubuntu , GHC == 9.6.7 -- cabal on Ubuntu @@ -26,6 +24,7 @@ tested-with: -- stack on FreeBSD, MacOS, Ubuntu, Windows , GHC == 9.10.3 -- cabal on Ubuntu + -- nix , GHC == 9.12.3 source-repository head