From b914a25de326dd937e3a1d05f4eefb46af6da7b4 Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Mon, 9 Sep 2024 19:43:39 +0200 Subject: define return in terms of pure, >> as *>, mappend as <> In preparation for deprecation, see https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/semigroup-monoid and https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/monad-of-no-return --- src/runtime/haskell/Data/Binary/Builder.hs | 2 +- src/runtime/haskell/Data/Binary/Get.hs | 4 ++-- src/runtime/haskell/Data/Binary/Put.hs | 14 ++++++++------ src/runtime/haskell/PGF/TypeCheck.hs | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/haskell/Data/Binary/Builder.hs b/src/runtime/haskell/Data/Binary/Builder.hs index 8dc46f816..e22fa4a4c 100644 --- a/src/runtime/haskell/Data/Binary/Builder.hs +++ b/src/runtime/haskell/Data/Binary/Builder.hs @@ -114,7 +114,7 @@ instance Semigroup Builder where instance Monoid Builder where mempty = empty {-# INLINE mempty #-} - mappend = append + mappend = (<>) {-# INLINE mappend #-} ------------------------------------------------------------------------ diff --git a/src/runtime/haskell/Data/Binary/Get.hs b/src/runtime/haskell/Data/Binary/Get.hs index a33c5c5a3..ec6309fae 100644 --- a/src/runtime/haskell/Data/Binary/Get.hs +++ b/src/runtime/haskell/Data/Binary/Get.hs @@ -127,11 +127,11 @@ instance Functor Get where {-# INLINE fmap #-} instance Applicative Get where - pure = return + pure a = Get (\s -> (a, s)) (<*>) = ap instance Monad Get where - return a = Get (\s -> (a, s)) + return = pure {-# INLINE return #-} m >>= k = Get (\s -> case unGet m s of diff --git a/src/runtime/haskell/Data/Binary/Put.hs b/src/runtime/haskell/Data/Binary/Put.hs index 189cf806f..05d23fba6 100644 --- a/src/runtime/haskell/Data/Binary/Put.hs +++ b/src/runtime/haskell/Data/Binary/Put.hs @@ -77,15 +77,20 @@ instance Functor PutM where {-# INLINE fmap #-} instance Applicative PutM where - pure = return + pure a = Put $ PairS a mempty m <*> k = Put $ let PairS f w = unPut m PairS x w' = unPut k in PairS (f x) (w `mappend` w') + m *> k = Put $ + let PairS _ w = unPut m + PairS b w' = unPut k + in PairS b (w `mappend` w') + {-# INLINE (*>) #-} -- Standard Writer monad, with aggressive inlining instance Monad PutM where - return a = Put $ PairS a mempty + return = pure {-# INLINE return #-} m >>= k = Put $ @@ -94,10 +99,7 @@ instance Monad PutM where in PairS b (w `mappend` w') {-# INLINE (>>=) #-} - m >> k = Put $ - let PairS _ w = unPut m - PairS b w' = unPut k - in PairS b (w `mappend` w') + (>>) = (*>) {-# INLINE (>>) #-} tell :: Builder -> Put diff --git a/src/runtime/haskell/PGF/TypeCheck.hs b/src/runtime/haskell/PGF/TypeCheck.hs index 82bd47b7a..f02986fc0 100644 --- a/src/runtime/haskell/PGF/TypeCheck.hs +++ b/src/runtime/haskell/PGF/TypeCheck.hs @@ -94,11 +94,11 @@ class Selector s where select :: CId -> Scope -> Maybe Int -> TcM s (Expr,TType) instance Applicative (TcM s) where - pure = return + pure x = TcM (\abstr k h -> k x) (<*>) = ap instance Monad (TcM s) where - return x = TcM (\abstr k h -> k x) + return = pure f >>= g = TcM (\abstr k h -> unTcM f abstr (\x -> unTcM (g x) abstr k h) h) instance Selector s => Alternative (TcM s) where -- cgit v1.2.3 From 01c4f82e077b93cb2318830c56070c0ec15a20e6 Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Sat, 2 Aug 2025 16:42:54 +0200 Subject: misc small fixes: - update actions/cache to v4 - update haskell/actions/setup to haskell-actions/setup - stack doesn't support ghc < 8.4, remove from CI - don't fail immediately - add -fpermissive flag to gcc - only build 9.6.6 with macos and windows latest - bump base upper bound --- .github/workflows/build-all-versions.yml | 17 +++++++++++------ gf.cabal | 4 ++-- src/runtime/c/configure.ac | 1 + 3 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src/runtime') diff --git a/.github/workflows/build-all-versions.yml b/.github/workflows/build-all-versions.yml index 2bd856b7c..0f3222809 100644 --- a/.github/workflows/build-all-versions.yml +++ b/.github/workflows/build-all-versions.yml @@ -12,6 +12,7 @@ jobs: name: ${{ matrix.os }} / ghc ${{ matrix.ghc }} runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] cabal: ["latest"] @@ -19,21 +20,26 @@ jobs: - "8.6.5" - "8.8.3" - "8.10.7" + - "9.6.6" exclude: - os: macos-latest ghc: 8.8.3 - os: macos-latest ghc: 8.6.5 + - os: macos-latest + ghc: 8.10.7 - os: windows-latest ghc: 8.8.3 - os: windows-latest ghc: 8.6.5 + - os: windows-latest + ghc: 8.10.7 steps: - uses: actions/checkout@v2 if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' - - uses: haskell/actions/setup@v2 + - uses: haskell-actions/setup@v2 id: setup-haskell-cabal name: Setup Haskell with: @@ -44,7 +50,7 @@ jobs: run: | cabal freeze - - uses: actions/cache@v1 + - uses: actions/cache@v4 name: Cache ~/.cabal/store with: path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }} @@ -66,14 +72,13 @@ jobs: strategy: matrix: stack: ["latest"] - ghc: ["7.10.3","8.0.2", "8.2.2", "8.4.4", "8.6.5", "8.8.4", "8.10.7", "9.0.2"] - # ghc: ["8.8.3"] + ghc: ["8.4.4", "8.6.5", "8.8.4", "8.10.7", "9.0.2", "9.6.6"] steps: - uses: actions/checkout@v2 if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' - - uses: haskell/actions/setup@v2 + - uses: haskell-actions/setup@v2 name: Setup Haskell Stack with: ghc-version: ${{ matrix.ghc }} @@ -85,7 +90,7 @@ jobs: - run: sed -i.bak 's/"C compiler link flags", "/&-no-pie /' /home/runner/.ghcup/ghc/7.10.3/lib/ghc-7.10.3/settings if: matrix.ghc == '7.10.3' - - uses: actions/cache@v1 + - uses: actions/cache@v4 name: Cache ~/.stack with: path: ~/.stack diff --git a/gf.cabal b/gf.cabal index 4b7e25a2d..ce0682d46 100644 --- a/gf.cabal +++ b/gf.cabal @@ -73,7 +73,7 @@ library build-depends: -- GHC 8.0.2 to GHC 8.10.4 array >= 0.5.1 && < 0.6, - base >= 4.9.1 && < 4.19 , + base >= 4.9.1 && < 4.22, bytestring >= 0.10.8 && < 0.12, containers >= 0.5.7 && < 0.7, exceptions >= 0.8.3 && < 0.11, @@ -398,7 +398,7 @@ test-suite gf-tests main-is: run.hs hs-source-dirs: testsuite build-depends: - base >= 4.9.1 && < 4.16, + base >= 4.9.1, Cabal >= 1.8, directory >= 1.3.0 && < 1.4, filepath >= 1.4.1 && < 1.5, diff --git a/src/runtime/c/configure.ac b/src/runtime/c/configure.ac index 2af669fe2..4e86e5251 100644 --- a/src/runtime/c/configure.ac +++ b/src/runtime/c/configure.ac @@ -30,6 +30,7 @@ AM_PROG_CC_C_O -Wall\ -Wextra\ -Wno-missing-field-initializers\ + -fpermissive\ -Wno-unused-parameter\ -Wno-unused-value" fi] -- cgit v1.2.3