Skip to content

Commit 4e80803

Browse files
committed
v0.2.2.1: drop support for GHC 7
1 parent 4931544 commit 4e80803

File tree

4 files changed

+67
-54
lines changed

4 files changed

+67
-54
lines changed

.github/workflows/haskell-ci.yml

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#
99
# For more information, see https://github.com/haskell-CI/haskell-ci
1010
#
11-
# version: 0.19.20250506
11+
# version: 0.19.20251211
1212
#
13-
# REGENDATA ("0.19.20250506",["github","newtype.cabal"])
13+
# REGENDATA ("0.19.20251211",["github","newtype.cabal"])
1414
#
1515
name: Haskell-CI
1616
on:
@@ -20,6 +20,9 @@ on:
2020
pull_request:
2121
branches:
2222
- master
23+
merge_group:
24+
branches:
25+
- master
2326
jobs:
2427
linux:
2528
name: Haskell-CI - Linux - ${{ matrix.compiler }}
@@ -32,14 +35,19 @@ jobs:
3235
strategy:
3336
matrix:
3437
include:
38+
- compiler: ghc-9.14.0.20251128
39+
compilerKind: ghc
40+
compilerVersion: 9.14.0.20251128
41+
setup-method: ghcup-prerelease
42+
allow-failure: false
3543
- compiler: ghc-9.12.2
3644
compilerKind: ghc
3745
compilerVersion: 9.12.2
3846
setup-method: ghcup
3947
allow-failure: false
40-
- compiler: ghc-9.10.2
48+
- compiler: ghc-9.10.3
4149
compilerKind: ghc
42-
compilerVersion: 9.10.2
50+
compilerVersion: 9.10.3
4351
setup-method: ghcup
4452
allow-failure: false
4553
- compiler: ghc-9.8.4
@@ -110,8 +118,8 @@ jobs:
110118
chmod a+x "$HOME/.ghcup/bin/ghcup"
111119
- name: Install cabal-install
112120
run: |
113-
"$HOME/.ghcup/bin/ghcup" install cabal 3.14.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
114-
echo "CABAL=$HOME/.ghcup/bin/cabal-3.14.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
121+
"$HOME/.ghcup/bin/ghcup" install cabal 3.16.0.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
122+
echo "CABAL=$HOME/.ghcup/bin/cabal-3.16.0.0 -vnormal+nowrap" >> "$GITHUB_ENV"
115123
- name: Install GHC (GHCup)
116124
if: matrix.setup-method == 'ghcup'
117125
run: |
@@ -126,6 +134,21 @@ jobs:
126134
HCKIND: ${{ matrix.compilerKind }}
127135
HCNAME: ${{ matrix.compiler }}
128136
HCVER: ${{ matrix.compilerVersion }}
137+
- name: Install GHC (GHCup prerelease)
138+
if: matrix.setup-method == 'ghcup-prerelease'
139+
run: |
140+
"$HOME/.ghcup/bin/ghcup" config add-release-channel prereleases
141+
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
142+
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
143+
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
144+
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
145+
echo "HC=$HC" >> "$GITHUB_ENV"
146+
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
147+
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
148+
env:
149+
HCKIND: ${{ matrix.compilerKind }}
150+
HCNAME: ${{ matrix.compiler }}
151+
HCVER: ${{ matrix.compilerVersion }}
129152
- name: Set PATH and environment variables
130153
run: |
131154
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
@@ -136,7 +159,7 @@ jobs:
136159
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
137160
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
138161
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV"
139-
echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
162+
if [ $((HCNUMVER >= 91400)) -ne 0 ] ; then echo "HEADHACKAGE=true" >> "$GITHUB_ENV" ; else echo "HEADHACKAGE=false" >> "$GITHUB_ENV" ; fi
140163
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
141164
env:
142165
HCKIND: ${{ matrix.compilerKind }}
@@ -164,6 +187,18 @@ jobs:
164187
repository hackage.haskell.org
165188
url: http://hackage.haskell.org/
166189
EOF
190+
if $HEADHACKAGE; then
191+
cat >> $CABAL_CONFIG <<EOF
192+
repository head.hackage.ghc.haskell.org
193+
url: https://ghc.gitlab.haskell.org/head.hackage/
194+
secure: True
195+
root-keys: 7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d
196+
26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329
197+
f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89
198+
key-threshold: 3
199+
active-repositories: hackage.haskell.org, head.hackage.ghc.haskell.org:override
200+
EOF
201+
fi
167202
cat >> $CABAL_CONFIG <<EOF
168203
program-default-options
169204
ghc-options: $GHCJOBS +RTS -M3G -RTS
@@ -187,7 +222,7 @@ jobs:
187222
chmod a+x $HOME/.cabal/bin/cabal-plan
188223
cabal-plan --version
189224
- name: checkout
190-
uses: actions/checkout@v4
225+
uses: actions/checkout@v5
191226
with:
192227
path: source
193228
- name: initial cabal.project for sdist
@@ -212,9 +247,16 @@ jobs:
212247
touch cabal.project.local
213248
echo "packages: ${PKGDIR_newtype}" >> cabal.project
214249
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package newtype" >> cabal.project ; fi
215-
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
250+
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods -Werror=missing-fields" >> cabal.project ; fi
251+
if [ $((HCNUMVER >= 90400)) -ne 0 ] ; then echo "package newtype" >> cabal.project ; fi
252+
if [ $((HCNUMVER >= 90400)) -ne 0 ] ; then echo " ghc-options: -Werror=unused-packages" >> cabal.project ; fi
253+
if [ $((HCNUMVER >= 90000)) -ne 0 ] ; then echo "package newtype" >> cabal.project ; fi
254+
if [ $((HCNUMVER >= 90000)) -ne 0 ] ; then echo " ghc-options: -Werror=incomplete-patterns -Werror=incomplete-uni-patterns" >> cabal.project ; fi
216255
cat >> cabal.project <<EOF
217256
EOF
257+
if $HEADHACKAGE; then
258+
echo "allow-newer: $($HCPKG list --simple-output | sed -E 's/([a-zA-Z-]+)-[0-9.]+/*:\1,/g')" >> cabal.project
259+
fi
218260
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(newtype)$/; }' >> cabal.project.local
219261
cat cabal.project
220262
cat cabal.project.local

CHANGES.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
See also https://pvp.haskell.org/faq
1+
## 0.2.2.1
2+
3+
- Drop support for GHC 7.
4+
- Tested with GHC 8.0 - 9.14.
25

36
## 0.2.2.0
47

Control/Newtype.hs

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
{-# LANGUAGE CPP #-}
2+
{-# LANGUAGE DefaultSignatures #-}
23
{-# LANGUAGE FlexibleInstances #-}
34
{-# LANGUAGE FunctionalDependencies #-}
45
{-# LANGUAGE MultiParamTypeClasses #-}
56
{-# LANGUAGE TypeFamilies #-}
6-
#if __GLASGOW_HASKELL__ >= 704
7-
{-# LANGUAGE DefaultSignatures #-}
8-
#endif
97

10-
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
8+
{-# OPTIONS_GHC -Wno-unused-imports #-}
119

1210
{- |
1311
Module : Control.Newtype
@@ -42,19 +40,14 @@ module Control.Newtype
4240

4341
import Control.Applicative
4442
import Control.Arrow
43+
44+
import Data.Coerce
4545
import Data.Fixed
4646
import Data.Functor.Compose
4747
import Data.Functor.Identity
4848
import Data.Monoid
4949
import Data.Ord
5050

51-
#if !MIN_VERSION_base(4,7,0)
52-
-- necessary evil for 'Newtype Fixed'
53-
import Unsafe.Coerce (unsafeCoerce)
54-
#else
55-
import Data.Coerce
56-
#endif
57-
5851
-- | Given a @newtype@ @n@, we will always have the same unwrapped type @o@, meaning we can represent this with a fundep @n -> o@.
5952
--
6053
-- Any instance of this class just needs to let 'pack' equal to the newtype's constructor, and let 'unpack' destruct the @newtype@ with pattern matching.
@@ -72,23 +65,11 @@ class Newtype n o | n -> o where
7265

7366
unpack :: n -> o
7467

75-
#if __GLASGOW_HASKELL__ >= 704
7668
default pack :: Coercible o n => o -> n
7769
pack = coerce
7870

7971
default unpack :: Coercible n o => n -> o
8072
unpack = coerce
81-
#endif
82-
83-
#if __GLASGOW_HASKELL__ >= 704 && !MIN_VERSION_base(4,7,0)
84-
-- Hack: We define a dummy 'Coercible' class to force a
85-
-- missing-instance compile error when methods are not explicitly
86-
-- defined
87-
class Coercible o n
88-
89-
coerce :: a -> b
90-
coerce = undefined
91-
#endif
9273

9374
{- TODO: for newtype-0.3
9475
@@ -196,37 +177,27 @@ instance ArrowApply a => Newtype (ArrowMonad a b) (a () b) where
196177

197178
-- | @since 0.2.1.0
198179
instance Newtype (Fixed a) Integer where
199-
#if MIN_VERSION_base(4,7,0)
200180
pack = MkFixed
201181
unpack (MkFixed x) = x
202-
#else
203-
-- 'Fixed' is a newtype, but its constructor wasn't exported before base-4.7.0
204-
pack = unsafeCoerce
205-
unpack = unsafeCoerce
206-
#endif
207182

208183
-- | @since 0.2.1.0
209184
instance Newtype (Dual a) a where
210185
pack = Dual
211186
unpack (Dual a) = a
212187

213-
#if MIN_VERSION_base(4,8,0)
214188
-- | __NOTE__: Type & instance only available with @base ≥ 4.8.0@
215189
--
216190
-- @since 0.2.1.0
217191
instance Newtype (Alt f a) (f a) where
218192
pack = Alt
219193
unpack (Alt x) = x
220-
#endif
221194

222-
#if MIN_VERSION_base(4,6,0)
223195
-- | __NOTE__: Type & instance only available with @base ≥ 4.6.0@
224196
--
225197
-- @since 0.2.1.0
226198
instance Newtype (Down a) a where
227199
pack = Down
228200
unpack (Down a) = a
229-
#endif
230201

231202
-- | @since 0.2.1.0
232203
instance Newtype (Identity a) a where

newtype.cabal

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
cabal-version: 1.12
22
build-type: Simple
33
name: newtype
4-
version: 0.2.2.0
5-
x-revision: 3
4+
version: 0.2.2.1
65

76
license: BSD3
87
license-file: LICENSE
@@ -15,8 +14,9 @@ synopsis: A typeclass and set of functions for working with newtypes.
1514
description: Per Conor McBride, the 'Newtype' typeclass represents the packing and unpacking of a @newtype@, and allows you to operate under that @newtype@ with functions such as 'ala'. See "Control.Newtype" for documentation and examples.
1615

1716
tested-with:
17+
GHC == 9.14.1
1818
GHC == 9.12.2
19-
GHC == 9.10.2
19+
GHC == 9.10.3
2020
GHC == 9.8.4
2121
GHC == 9.6.7
2222
GHC == 9.4.8
@@ -38,20 +38,17 @@ source-repository head
3838
library
3939
exposed-modules: Control.Newtype
4040

41-
build-depends: base >= 4.3 && < 5
42-
if !impl(ghc >= 8.0)
43-
build-depends: transformers >= 0.2.2.0 && < 0.6
41+
build-depends: base >= 4.9 && < 5
4442

4543
default-language: Haskell2010
4644
other-extensions:
4745
CPP
4846
FlexibleInstances
4947
FunctionalDependencies
5048
MultiParamTypeClasses
49+
Trustworthy
5150
TypeFamilies
5251

53-
if impl(ghc >= 7.2)
54-
default-extensions: Trustworthy
55-
if impl(ghc >= 7.10) { ghc-options: -fno-warn-trustworthy-safe }
56-
57-
ghc-options: -Wall
52+
ghc-options:
53+
-Wall
54+
-Wno-trustworthy-safe

0 commit comments

Comments
 (0)