Skip to content

Commit 4b9cc20

Browse files
authored
Merge pull request #70 from haskellari/eqp-superclass
Make EqP be as superclass of GEq, OrdP of GCompare
2 parents e292086 + 73d1a3e commit 4b9cc20

12 files changed

Lines changed: 74 additions & 192 deletions

File tree

.github/workflows/haskell-ci.yml

Lines changed: 6 additions & 36 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.20260209
11+
# version: 0.19.20260331
1212
#
13-
# REGENDATA ("0.19.20260209",["github","cabal.project"])
13+
# REGENDATA ("0.19.20260331",["github","cabal.project"])
1414
#
1515
name: Haskell-CI
1616
on:
@@ -62,36 +62,6 @@ jobs:
6262
compilerVersion: 9.6.7
6363
setup-method: ghcup
6464
allow-failure: false
65-
- compiler: ghc-9.4.8
66-
compilerKind: ghc
67-
compilerVersion: 9.4.8
68-
setup-method: ghcup
69-
allow-failure: false
70-
- compiler: ghc-9.2.8
71-
compilerKind: ghc
72-
compilerVersion: 9.2.8
73-
setup-method: ghcup
74-
allow-failure: false
75-
- compiler: ghc-9.0.2
76-
compilerKind: ghc
77-
compilerVersion: 9.0.2
78-
setup-method: ghcup
79-
allow-failure: false
80-
- compiler: ghc-8.10.4
81-
compilerKind: ghc
82-
compilerVersion: 8.10.4
83-
setup-method: ghcup
84-
allow-failure: false
85-
- compiler: ghc-8.8.4
86-
compilerKind: ghc
87-
compilerVersion: 8.8.4
88-
setup-method: ghcup
89-
allow-failure: false
90-
- compiler: ghc-8.6.5
91-
compilerKind: ghc
92-
compilerVersion: 8.6.5
93-
setup-method: ghcup
94-
allow-failure: false
9565
fail-fast: false
9666
steps:
9767
- name: apt-get install
@@ -217,10 +187,10 @@ jobs:
217187
echo "packages: ${PKGDIR_some}" >> cabal.project
218188
echo "package some" >> cabal.project
219189
echo " ghc-options: -Werror=missing-methods -Werror=missing-fields" >> cabal.project
220-
if [ $((HCNUMVER >= 90400)) -ne 0 ] ; then echo "package some" >> cabal.project ; fi
221-
if [ $((HCNUMVER >= 90400)) -ne 0 ] ; then echo " ghc-options: -Werror=unused-packages" >> cabal.project ; fi
222-
if [ $((HCNUMVER >= 90000)) -ne 0 ] ; then echo "package some" >> cabal.project ; fi
223-
if [ $((HCNUMVER >= 90000)) -ne 0 ] ; then echo " ghc-options: -Werror=incomplete-patterns -Werror=incomplete-uni-patterns" >> cabal.project ; fi
190+
echo "package some" >> cabal.project
191+
echo " ghc-options: -Werror=unused-packages" >> cabal.project
192+
echo "package some" >> cabal.project
193+
echo " ghc-options: -Werror=incomplete-patterns -Werror=incomplete-uni-patterns" >> cabal.project
224194
cat >> cabal.project <<EOF
225195
EOF
226196
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(some)$/; }' >> cabal.project.local

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 1.1
2+
3+
- Add `EqP` as a superclass of `GEq`, and `OrdP` as a superclass of `GCompare`.
4+
- Relax `Eq` and `Ord` instances of `Some` to require just `EqP` and `OrdP`.
5+
16
# 1.0.6
27

38
- Add instances for `SSymbol`, `SNat` and `SChar` from `base >=4.18.0.0'

some.cabal

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1+
cabal-version: 2.4
12
name: some
2-
version: 1.0.6
3-
x-revision: 3
4-
cabal-version: >=1.10
3+
version: 1.1
54
build-type: Simple
65
author:
76
James Cook <mokus@deepbondi.net>, Oleg Grenrus <oleg.grenrus@iki.fi>
87

98
maintainer: Oleg Grenrus <oleg.grenrus@iki.fi>
10-
license: BSD3
9+
license: BSD-3-Clause
1110
license-file: LICENSE
1211
homepage: https://github.com/haskellari/some
1312
category: Data, Dependent Types
@@ -25,19 +24,13 @@ description:
2524
If you are unsure which variant to use, use the one in "Data.Some" module.
2625

2726
tested-with:
28-
GHC ==8.6.5
29-
|| ==8.8.4
30-
|| ==8.10.4
31-
|| ==9.0.2
32-
|| ==9.2.8
33-
|| ==9.4.8
34-
|| ==9.6.7
27+
GHC ==9.6.7
3528
|| ==9.8.4
3629
|| ==9.10.2
3730
|| ==9.12.2
3831
|| ==9.14.1
3932

40-
extra-source-files: ChangeLog.md
33+
extra-doc-files: ChangeLog.md
4134

4235
flag newtype-unsafe
4336
description:
@@ -72,20 +65,15 @@ library
7265

7366
other-modules: Data.GADT.Internal
7467
build-depends:
75-
base >=4.12 && <4.23
76-
, deepseq >=1.4.4.0 && <1.6
68+
base >=4.18 && <4.23
69+
, deepseq >=1.4.8.1 && <1.6
7770

7871
if !impl(ghc >= 9.8)
7972
build-depends:
8073
base-orphans >= 0.9.1 && <0.10
8174

82-
if impl(ghc >=9.0)
83-
-- these flags may abort compilation with GHC-8.10
84-
-- https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3295
85-
ghc-options: -Winferred-safe-imports -Wmissing-safe-haskell-mode
86-
87-
if impl(ghc >=9.1)
88-
ghc-options: -Wmissing-kind-signatures
75+
ghc-options: -Winferred-safe-imports -Wmissing-safe-haskell-mode
76+
ghc-options: -Wmissing-kind-signatures
8977

9078
test-suite hkd-example
9179
default-language: Haskell2010

src/Data/EqP.hs

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
1-
{-# LANGUAGE CPP #-}
2-
{-# LANGUAGE PolyKinds #-}
3-
{-# LANGUAGE QuantifiedConstraints #-}
4-
{-# LANGUAGE Safe #-}
5-
{-# LANGUAGE TypeOperators #-}
6-
#if __GLASGOW_HASKELL__ >= 810
1+
{-# LANGUAGE CPP #-}
2+
{-# LANGUAGE PolyKinds #-}
3+
{-# LANGUAGE QuantifiedConstraints #-}
4+
{-# LANGUAGE Safe #-}
75
{-# LANGUAGE StandaloneKindSignatures #-}
8-
#endif
6+
{-# LANGUAGE TypeOperators #-}
97
module Data.EqP (
108
EqP (..),
119
) where
1210

1311
import Control.Applicative (Const (..))
14-
import Data.Kind (Type)
12+
import Data.Kind (Constraint, Type)
1513
import Data.Proxy (Proxy (..))
1614
import Data.Type.Equality ((:~:) (..), (:~~:) (..))
1715
import GHC.Generics ((:*:) (..), (:+:) (..))
1816
import System.Mem.StableName (StableName, eqStableName)
17+
import Data.Functor.Product (Product (..))
18+
import Data.Functor.Sum (Sum (..))
1919

20-
#if MIN_VERSION_base(4,18,0)
21-
import Data.Functor.Product (Product (..))
22-
import Data.Functor.Sum (Sum (..))
23-
import qualified GHC.TypeLits as TL
24-
import qualified GHC.TypeNats as TN
25-
#endif
20+
import qualified GHC.TypeLits as TL
21+
import qualified GHC.TypeNats as TN
2622

2723
#if !MIN_VERSION_base(4,19,0)
2824
import Data.Orphans ()
2925
#endif
3026

3127
import qualified Type.Reflection as TR
3228

33-
#if __GLASGOW_HASKELL__ >= 810
34-
import Data.Kind (Constraint)
35-
#endif
3629

3730
-- | Heterogenous lifted equality.
3831
--
@@ -60,9 +53,7 @@ import Data.Kind (Constraint)
6053
-- /Note:/ P stands for phantom.
6154
--
6255
-- @since 1.0.5
63-
#if __GLASGOW_HASKELL__ >= 810
6456
type EqP :: (k -> Type) -> Constraint
65-
#endif
6657
class (forall a. Eq (f a)) => EqP (f :: k -> Type) where
6758
eqp :: f a -> f b -> Bool
6859

@@ -72,16 +63,13 @@ instance EqP ((:~:) a) where
7263
instance EqP ((:~~:) a) where
7364
eqp _ _ = True
7465

75-
76-
#if MIN_VERSION_base(4,18,0)
7766
instance (EqP a, EqP b) => EqP (Sum a b) where
7867
eqp (InL x) (InL y) = eqp x y
7968
eqp (InR x) (InR y) = eqp x y
8069
eqp _ _ = False
8170

8271
instance (EqP a, EqP b) => EqP (Product a b) where
8372
eqp (Pair x y) (Pair x' y') = eqp x x' && eqp y y'
84-
#endif
8573

8674
instance (EqP f, EqP g) => EqP (f :+: g) where
8775
eqp (L1 x) (L1 y) = eqp x y
@@ -94,7 +82,6 @@ instance (EqP a, EqP b) => EqP (a :*: b) where
9482
instance EqP TR.TypeRep where
9583
eqp x y = TR.SomeTypeRep x == TR.SomeTypeRep y
9684

97-
#if MIN_VERSION_base(4,18,0)
9885
instance EqP TL.SChar where
9986
eqp x y = TL.fromSChar x == TL.fromSChar y
10087

@@ -103,7 +90,6 @@ instance EqP TL.SSymbol where
10390

10491
instance EqP TN.SNat where
10592
eqp x y = TN.fromSNat x == TN.fromSNat y
106-
#endif
10793

10894
instance EqP Proxy where
10995
eqp _ _ = True

src/Data/GADT/Compare.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{-# LANGUAGE CPP #-}
21
{-# LANGUAGE Safe #-}
32
module Data.GADT.Compare (
43
-- * Equality

src/Data/GADT/DeepSeq.hs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
1-
{-# LANGUAGE CPP #-}
21
{-# LANGUAGE GADTs #-}
32
{-# LANGUAGE PolyKinds #-}
43
{-# LANGUAGE Safe #-}
5-
{-# LANGUAGE TypeOperators #-}
6-
#if __GLASGOW_HASKELL__ >= 810
74
{-# LANGUAGE StandaloneKindSignatures #-}
8-
#endif
5+
{-# LANGUAGE TypeOperators #-}
96
module Data.GADT.DeepSeq (
107
GNFData (..),
118
) where
129

1310
import Data.Functor.Product (Product (..))
1411
import Data.Functor.Sum (Sum (..))
12+
import Data.Kind (Constraint, Type)
1513
import Data.Type.Equality ((:~:) (..), (:~~:) (..))
1614
import GHC.Generics ((:*:) (..), (:+:) (..))
1715

1816
import qualified Type.Reflection as TR
1917

20-
#if __GLASGOW_HASKELL__ >= 810
21-
import Data.Kind (Constraint, Type)
22-
#endif
23-
24-
#if __GLASGOW_HASKELL__ >= 810
2518
type GNFData :: (k -> Type) -> Constraint
26-
#endif
27-
2819
class GNFData f where
2920
grnf :: f a -> ()
3021

0 commit comments

Comments
 (0)