Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GHC 9.6 build #290

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 41 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,49 @@
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
};
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = inputs.nixpkgs.lib.systems.flakeExposed;
imports = [ inputs.haskell-flake.flakeModule ];
perSystem = { self', pkgs, config, ... }: {
packages.default = self'.packages.fortran-src;
haskellProjects.default = {};
packages.default = self'.packages.fortran-src-ghc92-fortran-src;
devShells.default = self'.devShells.fortran-src-ghc92;

haskellProjects.ghc92 = import ./haskell-flake-ghc92.nix pkgs;
haskellProjects.fortran-src-ghc92 = {
basePackages = config.haskellProjects.ghc92.outputs.finalPackages;
devShell = {
tools = hp: {
# use nixpkgs cabal-install
cabal-install = pkgs.cabal-install;

# disable these while unused (often slow/annoying to build)
haskell-language-server = null;
ghcid = null;
hlint = null;
};
};
};

haskellProjects.ghc94 = import ./haskell-flake-ghc94.nix pkgs;
haskellProjects.fortran-src-ghc94 = {
basePackages = config.haskellProjects.ghc94.outputs.finalPackages;
devShell = {
tools = hp: {
# use nixpkgs cabal-install
cabal-install = pkgs.cabal-install;

# disable these while unused (often slow/annoying to build)
haskell-language-server = null;
ghcid = null;
hlint = null;
};
};
};

haskellProjects.ghc96 = {
basePackages = pkgs.haskell.packages.ghc96;
};
};
};
}
20 changes: 10 additions & 10 deletions fortran-src.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.37.0.
-- This file has been generated from package.yaml by hpack version 0.35.2.
--
-- see: https://github.com/sol/hpack

Expand Down Expand Up @@ -200,9 +200,9 @@ library
, mtl >=2.2 && <3
, pretty >=1.1 && <2
, process >=1.2.0.0
, singletons >=3.0 && <3.2
, singletons-base >=3.0 && <3.2
, singletons-th >=3.0 && <3.2
, singletons ==3.0.*
, singletons-base >=3.0 && <3.3
, singletons-th >=3.0 && <3.3
, temporary >=1.2 && <1.4
, text >=1.2 && <2.1
, uniplate >=1.6 && <2
Expand Down Expand Up @@ -264,9 +264,9 @@ executable fortran-src
, mtl >=2.2 && <3
, pretty >=1.1 && <2
, process >=1.2.0.0
, singletons >=3.0 && <3.2
, singletons-base >=3.0 && <3.2
, singletons-th >=3.0 && <3.2
, singletons ==3.0.*
, singletons-base >=3.0 && <3.3
, singletons-th >=3.0 && <3.3
, temporary >=1.2 && <1.4
, text >=1.2 && <2.1
, uniplate >=1.6 && <2
Expand Down Expand Up @@ -363,9 +363,9 @@ test-suite spec
, mtl >=2.2 && <3
, pretty >=1.1 && <2
, process >=1.2.0.0
, singletons >=3.0 && <3.2
, singletons-base >=3.0 && <3.2
, singletons-th >=3.0 && <3.2
, singletons ==3.0.*
, singletons-base >=3.0 && <3.3
, singletons-th >=3.0 && <3.3
, temporary >=1.2 && <1.4
, text >=1.2 && <2.1
, uniplate >=1.6 && <2
Expand Down
30 changes: 30 additions & 0 deletions haskell-flake-ghc92.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
pkgs: {
# disable local project options (always do this for package sets)
defaults.packages = {};
devShell.enable = false;
autoWire = [];

basePackages = pkgs.haskell.packages.ghc92;
packages = {
# GHC 9.2 libraries
singletons-th.source = "3.1";
singletons-base.source = "3.1";
singletons.source = "3.0.1"; # req because singletons-th-3.1 had bad bounds
th-desugar.source = "1.13.1";
th-abstraction.source = "0.4.5.0";
};

# (note this is actually unused/we have to duplicate because it doesn't get
# packed into basePackages or any key we can use... but nice to document here)
devShell = {
tools = hp: {
# by default, haskell-flake uses the Haskell packages versions of these
# tools (from hp). be warned, these can be a pain to build alternatively,
# you may use nixpkgs versions via pkgs

# as of 2024-09-13 nixpkgs-unstable can't build cabal-install on GHC 9.2.
# no problem, use nixpkgs version (shouldn't really matter how built)
cabal-install = pkgs.cabal-install;
};
};
}
30 changes: 30 additions & 0 deletions haskell-flake-ghc94.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
pkgs: {
# disable local project options (always do this for package sets)
defaults.packages = {};
devShell.enable = false;
autoWire = [];

basePackages = pkgs.haskell.packages.ghc94;
packages = {
# GHC 9.4 libraries
singletons-th.source = "3.1.1";
singletons-base.source = "3.1.1";
#singletons.source = "3.0.1";
th-desugar.source = "1.14";
th-abstraction.source = "0.4.5.0";
};

# (note this is actually unused/we have to duplicate because it doesn't get
# packed into basePackages or any key we can use... but nice to document here)
devShell = {
tools = hp: {
# by default, haskell-flake uses the Haskell packages versions of these
# tools (from hp). be warned, these can be a pain to build alternatively,
# you may use nixpkgs versions via pkgs

# as of 2024-09-13 nixpkgs-unstable can't build cabal-install on GHC 9.4.
# no problem, use nixpkgs version (shouldn't really matter how built)
cabal-install = pkgs.cabal-install;
};
};
}
9 changes: 5 additions & 4 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ dependencies:
- either ^>=5.0.1.1
- process >= 1.2.0.0

# 3.0 requires GHC 9.0; 3.1 requires GHC 9.2
- singletons >= 3.0 && < 3.2
- singletons-th >= 3.0 && < 3.2
- singletons-base >= 3.0 && < 3.2
- singletons >= 3.0 && < 3.1

# 3.0 = GHC 9.0, 3.1 = GHC 9.2, 3.1.1 = GHC 9.4, 3.2 = GHC 9.6
- singletons-th >= 3.0 && < 3.3
- singletons-base >= 3.0 && < 3.3

library:
source-dirs: src
Expand Down
1 change: 1 addition & 0 deletions src/Language/Fortran/Analysis/BBlocks.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import Control.Monad
import Control.Monad.State.Lazy hiding (fix)
import Control.Monad.Writer hiding (fix)
import Control.Monad ( forM_ ) -- required for mtl-2.3 (GHC 9.6)

Check warning on line 16 in src/Language/Fortran/Analysis/BBlocks.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.2, Cabal / test

The import of ‘Control.Monad’ is redundant

Check warning on line 16 in src/Language/Fortran/Analysis/BBlocks.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.0, Cabal / test

The import of ‘Control.Monad’ is redundant
import Text.PrettyPrint.GenericPretty (pretty, Out)
import Text.PrettyPrint (render)
import Language.Fortran.Analysis
Expand Down Expand Up @@ -197,7 +198,7 @@
| exit, PUFunction{} <- pu = zipWith genAssign (genVar a0 noSrcSpan fn:vs) [(0::Integer)..]
| otherwise = zipWith genAssign vs [(1::Integer)..]
where
Named fn = puName pu

Check warning on line 201 in src/Language/Fortran/Analysis/BBlocks.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.2, Cabal / test

Pattern match(es) are non-exhaustive
name i = fn ++ "[" ++ show i ++ "]"
a0 = head $ initAnalysis [prevAnnotation a]
(a, s, vs) = case pu of
Expand Down
1 change: 1 addition & 0 deletions src/Language/Fortran/Analysis/DataFlow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import Language.Fortran.Analysis
import Language.Fortran.Analysis.BBlocks (showBlock, ASTBlockNode, ASTExprNode)
import Language.Fortran.AST
import Language.Fortran.AST.Literal.Real

Check warning on line 35 in src/Language/Fortran/Analysis/DataFlow.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.0, Cabal / test

The import of ‘Language.Fortran.AST.Literal.Real’ is redundant
import qualified Data.Map as M
import qualified Data.IntMap.Lazy as IM
import qualified Data.IntMap.Strict as IMS
Expand All @@ -42,6 +42,7 @@
import Data.Maybe
import Data.List (foldl', foldl1', (\\), union, intersect)
import Control.Monad.Writer hiding (fix)
import Control.Monad -- required for mtl-2.3 (GHC 9.6)

Check warning on line 45 in src/Language/Fortran/Analysis/DataFlow.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.0, Cabal / test

The import of ‘Control.Monad’ is redundant

import qualified Language.Fortran.Repr as Repr
import qualified Language.Fortran.Repr.Eval.Value as Repr
Expand Down Expand Up @@ -349,13 +350,13 @@

-- conservative assumption: stay within bounds of signed 32-bit integer
minConst :: Integer
minConst = (-2::Integer) ^ (31::Integer)

Check warning on line 353 in src/Language/Fortran/Analysis/DataFlow.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.0, Cabal / test

Defined but not used: ‘minConst’

maxConst :: Integer
maxConst = (2::Integer) ^ (31::Integer) - (1::Integer)

Check warning on line 356 in src/Language/Fortran/Analysis/DataFlow.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.0, Cabal / test

Defined but not used: ‘maxConst’

inBounds :: Integer -> Bool
inBounds x = minConst <= x && x <= maxConst

Check warning on line 359 in src/Language/Fortran/Analysis/DataFlow.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.0, Cabal / test

Defined but not used: ‘inBounds’

-- | The map of all parameter variables and their corresponding values
type ParameterVarMap = M.Map Name Repr.FValue
Expand Down Expand Up @@ -403,7 +404,7 @@
[(varName v, e) | (Declarator _ _ v ScalarDecl _ (Just e)) <- universeBi stmt ]
_ -> []
-- Now process these decls
forM_ internalDecls (\(v, e) -> modify (\map ->

Check warning on line 407 in src/Language/Fortran/Analysis/DataFlow.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.0, Cabal / test

This binding for ‘map’ shadows the existing binding
case getE0 map e of
Just evalExpr -> M.insert v evalExpr map
Nothing -> map))
Expand Down
2 changes: 1 addition & 1 deletion src/Language/Fortran/Analysis/ModGraph.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import Language.Fortran.Util.ModFile
import Language.Fortran.Util.Files

import Prelude hiding (mod)
import Control.Monad
import Control.Monad.State.Strict
import Control.Monad ( forM_ ) -- required for mtl-2.3 (GHC 9.6)
import Data.Data
import Data.Generics.Uniplate.Data
import Data.Graph.Inductive hiding (version)
Expand Down
1 change: 1 addition & 0 deletions src/Language/Fortran/Analysis/Renaming.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import Data.Map (insert, empty, lookup, Map)
import qualified Data.Map.Strict as M
import Control.Monad.State.Strict
import Control.Monad -- required for mtl-2.3 (GHC 9.6)

Check warning on line 23 in src/Language/Fortran/Analysis/Renaming.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.2, Cabal / test

The import of ‘Control.Monad’ is redundant

Check warning on line 23 in src/Language/Fortran/Analysis/Renaming.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.0, Cabal / test

The import of ‘Control.Monad’ is redundant
import Data.Generics.Uniplate.Data
import Data.Data
import Data.Functor.Identity (Identity)
Expand All @@ -45,13 +46,13 @@
analyseRenames :: Data a => ProgramFile (Analysis a) -> ProgramFile (Analysis a)
analyseRenames (ProgramFile mi pus) = cleanupUseRenames $ ProgramFile mi pus'
where
(Just pus', _) = runRenamer (renameSubPUs (Just pus)) (renameState0 (miVersion mi))

Check warning on line 49 in src/Language/Fortran/Analysis/Renaming.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.2, Cabal / test

Pattern match(es) are non-exhaustive

-- | Annotate unique names for variable and function declarations and uses. With external module map.
analyseRenamesWithModuleMap :: Data a => ModuleMap -> ProgramFile (Analysis a) -> ProgramFile (Analysis a)
analyseRenamesWithModuleMap mmap (ProgramFile mi pus) = cleanupUseRenames $ ProgramFile mi pus'
where
(Just pus', _) = runRenamer (renameSubPUs (Just pus)) (renameState0 (miVersion mi)) { moduleMap = mmap }

Check warning on line 55 in src/Language/Fortran/Analysis/Renaming.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.2, Cabal / test

Pattern match(es) are non-exhaustive

-- | Take the unique name annotations and substitute them into the actual AST.
rename :: Data a => ProgramFile (Analysis a) -> ProgramFile (Analysis a)
Expand Down Expand Up @@ -112,7 +113,7 @@
return (PUModule a' s name blocks3 m_contains')

programUnit (PUFunction a s ty rec name args res blocks m_contains) = do
~(Just name') <- getFromEnv name -- get renamed function name

Check warning on line 116 in src/Language/Fortran/Analysis/Renaming.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.2, Cabal / test

Pattern match(es) are non-exhaustive
(blocks1, _) <- returnBlocksEnv blocks name
blocks2 <- mapM renameEntryPointResultDecl blocks1 -- rename the result
res' <- mapM renameGenericDecls res -- variable(s) if needed
Expand All @@ -127,7 +128,7 @@
return . setSourceName name . setUniqueName name' $ pu'

programUnit (PUSubroutine a s rec name args blocks m_contains) = do
~(Just name') <- getFromEnv name -- get renamed subroutine name

Check warning on line 131 in src/Language/Fortran/Analysis/Renaming.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.2, Cabal / test

Pattern match(es) are non-exhaustive
(blocks1, _) <- returnBlocksEnv blocks name
args' <- mapM renameGenericDecls args -- rename arguments
blocks2 <- mapM renameDeclDecls blocks1 -- handle declarations
Expand Down Expand Up @@ -239,7 +240,7 @@
| only <- aStrip onlyAList -> do
let env = fromMaybe empty (Named m `lookup` mMap)
-- mark as imported all the local things from this module
env <- return $ M.map (\ (v, info) -> (v, markAsImported info)) env

Check warning on line 243 in src/Language/Fortran/Analysis/Renaming.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.2, Cabal / test

This binding for ‘env’ shadows the existing binding

Check warning on line 243 in src/Language/Fortran/Analysis/Renaming.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.0, Cabal / test

This binding for ‘env’ shadows the existing binding
-- list of (local name, original name) from USE declaration:
let localNamePairs = flip mapMaybe only $ \ r -> case r of
UseID _ _ v@(ExpValue _ _ ValVariable{}) -> Just (varName v, varName v)
Expand Down
1 change: 1 addition & 0 deletions src/Language/Fortran/Analysis/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import Data.List (find, foldl')
import Control.Monad.State.Strict
import Control.Monad.Reader
import Control.Monad -- required for mtl-2.3 (GHC 9.6)

Check warning on line 26 in src/Language/Fortran/Analysis/Types.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.2, Cabal / test

The import of ‘Control.Monad’ is redundant

Check warning on line 26 in src/Language/Fortran/Analysis/Types.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.0, Cabal / test

The import of ‘Control.Monad’ is redundant
import Data.Generics.Uniplate.Data
import Data.Data
import Language.Fortran.Analysis
Expand Down Expand Up @@ -682,7 +683,7 @@
Nothing ->
-- got RHS len, no Selector (e.g. @CHARACTER :: x*3 = "sup"@)
-- naughty let binding to avoid re-hardcoding default char kind
let (TCharacter _ k) = deriveSemTypeFromBaseType TypeCharacter

Check warning on line 686 in src/Language/Fortran/Analysis/Types.hs

View workflow job for this annotation

GitHub Actions / Ubuntu / GHC 9.2, Cabal / test

Pattern match(es) are non-exhaustive
in return $ TCharacter (charLenSelector' lenExpr) k

-- | Attempt to derive a 'SemType' from a 'TypeSpec'.
Expand Down
1 change: 0 additions & 1 deletion src/Language/Fortran/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ module Language.Fortran.Parser

-- * Other parsers
, f90Expr
, f77lIncludesNoTransform
, byVerFromFilename

-- ** Statement
Expand Down
1 change: 1 addition & 0 deletions src/Language/Fortran/Util/ModFile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import qualified Language.Fortran.Util.Position as P
import Language.Fortran.Util.Files ( getDirContents )

import Control.Monad.State
import Control.Monad -- required for mtl-2.3 (GHC 9.6)
import Data.Binary (Binary, encode, decodeOrFail)
import qualified Data.ByteString.Lazy.Char8 as LB
import Data.Data
Expand Down
2 changes: 1 addition & 1 deletion test/Language/Fortran/Parser/Free/Fortran95Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import qualified Language.Fortran.Parser.Free.Fortran95 as F95
import qualified Language.Fortran.Parser.Free.Lexer as Free

import qualified Data.List as List
import Data.Foldable(forM_)
import Control.Monad ( forM_ )
import qualified Data.ByteString.Char8 as B
import Control.Exception (evaluate)

Expand Down
Loading