Skip to content

Commit b2b9b38

Browse files
committed
Modernize for GHC 9: DevTools, formatting, CI, and compatibility fixes
- Add Nix flake with DevTools (direnv, treefmt, lefthook) - Format codebase using treefmt (Ormolu) - Add GitHub Actions CI workflow with submodule support - Update all submodules to modernized versions - Fix random-fu API migration (IORef PureMT -> AtomicGenM PureMT) - Drop random-source dependency (incompatible with GHC 9) - Add AllowAmbiguousTypes for GHC 9 type family changes - Add missing dependencies (random, linear-vect) to cabal file - Update stack.yaml resolver to lts-22.11
1 parent b563a0a commit b2b9b38

39 files changed

Lines changed: 2334 additions & 1733 deletions

.claude/settings.local.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(stack build:*)",
5+
"Bash(stack exec:*)"
6+
]
7+
}
8+
}

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [ master, main ]
5+
pull_request:
6+
branches: [ master, main ]
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
submodules: recursive
15+
- uses: cachix/install-nix-action@v25
16+
with:
17+
nix_path: nixpkgs=channel:nixos-unstable
18+
- name: Check formatting
19+
run: nix fmt -- --check
20+
- name: Build
21+
run: nix develop --command stack build --system-ghc

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.direnv
2+
.stack-work
3+
dist-newstyle/

VirMat.cabal

Lines changed: 74 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,80 @@
1-
Name: VirMat
2-
Version: 0.4.1
3-
License: GPL-3
4-
License-file: LICENSE
5-
Author: Edgar Gomes de Araujo
6-
Maintainer: Edgar Gomes de Araujo <talktoedgar@gmail.com>
7-
Homepage:
8-
Stability: Experimental
9-
Synopsis: 3D Microstructure Generator
10-
Description:
11-
Creates virtual microstructure in 3 dimesions.
12-
Cabal-version: >= 1.8
13-
Build-type: Simple
14-
Category: Data, Math
1+
name: VirMat
2+
version: 0.4.1
3+
license: GPL-3
4+
license-file: LICENSE
5+
author: Edgar Gomes de Araujo
6+
maintainer: Edgar Gomes de Araujo <talktoedgar@gmail.com>
7+
homepage:
8+
stability: Experimental
9+
synopsis: 3D Microstructure Generator
10+
description: Creates virtual microstructure in 3 dimesions.
11+
cabal-version: >=1.8
12+
build-type: Simple
13+
category: Data, Math
1514

16-
Flag generator
17-
Description: Build the exectable using command line.
18-
Default: True
15+
flag generator
16+
description: Build the exectable using command line.
17+
default: True
1918

20-
Executable virmatgen
21-
hs-source-dirs: src
22-
main-is: Main.hs
23-
ghc-options: -Wall
24-
-O3
25-
-threaded
26-
-rtsopts
27-
-auto-all
28-
-caf-all
19+
executable virmatgen
20+
hs-source-dirs: src
21+
main-is: Main.hs
22+
ghc-options: -Wall -O3 -threaded -rtsopts -auto-all -caf-all
23+
build-depends:
24+
base >=4 && <5
25+
, containers >=0.5
26+
, DeUni >=0.3
27+
, hammer >=0.3
28+
, linear-vect >=0.2
29+
, mersenne-random-pure64 >=0.2
30+
, mtl >=2.1
31+
, optparse-applicative >=0.7
32+
, random >=1.2
33+
, random-fu >=0.2
34+
, sledge >=0.3
35+
, SubZero >=0.1
36+
, transformers >=0.3
37+
, unordered-containers >=0.2
38+
, vector >=0.10
39+
, VirMat
2940

30-
Build-Depends: VirMat
31-
, base == 4.*
32-
, hammer >= 0.3
33-
, sledge >= 0.3
34-
, DeUni >= 0.3
35-
, containers >= 0.5
36-
, unordered-containers >= 0.2
37-
, vector >= 0.10
38-
, SubZero >= 0.1
39-
, mersenne-random-pure64 >= 0.2
40-
, random-source >= 0.3
41-
, random-fu >= 0.2
42-
, transformers >= 0.3
43-
, mtl >= 2.1
44-
, optparse-applicative >= 0.7
45-
if flag(generator)
46-
Buildable: True
47-
else
48-
Buildable: False
41+
if flag(generator)
42+
buildable: True
4943

50-
library
51-
ghc-options: -Wall
52-
-fwarn-tabs
53-
-funbox-strict-fields
54-
-O2
55-
hs-source-dirs: src
56-
Build-Depends: base == 4.*
57-
, hammer >= 0.3
58-
, sledge >= 0.3
59-
, DeUni >= 0.3
60-
, containers >= 0.5
61-
, unordered-containers >= 0.2
62-
, vector >= 0.10
63-
, SubZero >= 0.1
64-
, mersenne-random-pure64 >= 0.2
65-
, random-source >= 0.3
66-
, random-fu >= 0.2
67-
, transformers >= 0.3
68-
, mtl >= 2.1
69-
, linear-vect >= 0.2
70-
71-
Exposed-modules: VirMat.Run2D
72-
VirMat.Run3D
73-
VirMat.Types
74-
75-
VirMat.Core.Packer
76-
VirMat.Core.Sampling
77-
VirMat.Core.VoronoiMicro
78-
VirMat.Core.FlexMicro
44+
else
45+
buildable: False
7946

80-
VirMat.Distributions.GrainSize.GrainDistributionGenerator
81-
VirMat.Distributions.GrainSize.GrainQuery
82-
VirMat.Distributions.Texture.ODFSampling
83-
84-
VirMat.IO.Export.ANG.RasterEngine
85-
VirMat.IO.Export.Types
86-
87-
VirMat.IO.Import.Types
47+
library
48+
ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2
49+
hs-source-dirs: src
50+
build-depends:
51+
base >=4 && <5
52+
, containers >=0.5
53+
, DeUni >=0.3
54+
, hammer >=0.3
55+
, linear-vect >=0.2
56+
, mersenne-random-pure64 >=0.2
57+
, mtl >=2.1
58+
, random >=1.2
59+
, random-fu >=0.2
60+
, sledge >=0.3
61+
, SubZero >=0.1
62+
, transformers >=0.3
63+
, unordered-containers >=0.2
64+
, vector >=0.10
8865

89-
VirMat.PhaseTrans
66+
exposed-modules:
67+
VirMat.Core.FlexMicro
68+
VirMat.Core.Packer
69+
VirMat.Core.Sampling
70+
VirMat.Core.VoronoiMicro
71+
VirMat.Distributions.GrainSize.GrainDistributionGenerator
72+
VirMat.Distributions.GrainSize.GrainQuery
73+
VirMat.Distributions.Texture.ODFSampling
74+
VirMat.IO.Export.ANG.RasterEngine
75+
VirMat.IO.Export.Types
76+
VirMat.IO.Import.Types
77+
VirMat.PhaseTrans
78+
VirMat.Run2D
79+
VirMat.Run3D
80+
VirMat.Types

flake.lock

Lines changed: 82 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
description = "VirMat - 3D Microstructure Generator";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
treefmt-nix = {
8+
url = "github:numtide/treefmt-nix";
9+
inputs.nixpkgs.follows = "nixpkgs";
10+
};
11+
};
12+
13+
outputs = { self, nixpkgs, flake-utils, treefmt-nix }:
14+
flake-utils.lib.eachDefaultSystem (system:
15+
let
16+
pkgs = import nixpkgs { inherit system; };
17+
18+
treefmtWrapper = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
19+
20+
haskellStack = pkgs.haskellPackages.ghc;
21+
22+
hls = pkgs.haskell-language-server;
23+
24+
in
25+
{
26+
formatter = treefmtWrapper.config.build.wrapper;
27+
28+
devShells.default = pkgs.mkShell {
29+
buildInputs = [
30+
haskellStack
31+
pkgs.stack
32+
pkgs.cabal-install
33+
hls
34+
pkgs.pkg-config
35+
pkgs.zlib
36+
pkgs.clang
37+
treefmtWrapper.config.build.wrapper
38+
pkgs.nixpkgs-fmt
39+
pkgs.lefthook
40+
];
41+
42+
shellHook = ''
43+
echo "VirMat Dev Environment Loaded"
44+
echo "GHC version: $(ghc --version)"
45+
'';
46+
};
47+
}
48+
);
49+
}

lefthook.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pre-commit:
2+
commands:
3+
format:
4+
glob: "*"
5+
run: nix fmt {staged_files} && git add {staged_files}

0 commit comments

Comments
 (0)