Skip to content

Commit a4d0e9a

Browse files
committed
Add Solo instances
1 parent 5d185c5 commit a4d0e9a

File tree

5 files changed

+141
-30
lines changed

5 files changed

+141
-30
lines changed

.github/workflows/haskell-ci.yml

+86-26
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.12
11+
# version: 0.13.20211030
1212
#
13-
# REGENDATA ("0.12",["github","--config=cabal.haskell-ci","lattices.cabal"])
13+
# REGENDATA ("0.13.20211030",["github","--config=cabal.haskell-ci","lattices.cabal"])
1414
#
1515
name: Haskell-CI
1616
on:
@@ -30,59 +30,118 @@ jobs:
3030
strategy:
3131
matrix:
3232
include:
33+
- compiler: ghc-9.2.1
34+
compilerKind: ghc
35+
compilerVersion: 9.2.1
36+
setup-method: ghcup
37+
allow-failure: false
3338
- compiler: ghc-9.0.1
39+
compilerKind: ghc
40+
compilerVersion: 9.0.1
41+
setup-method: hvr-ppa
3442
allow-failure: false
3543
- compiler: ghc-8.10.4
44+
compilerKind: ghc
45+
compilerVersion: 8.10.4
46+
setup-method: hvr-ppa
3647
allow-failure: false
3748
- compiler: ghc-8.8.3
49+
compilerKind: ghc
50+
compilerVersion: 8.8.3
51+
setup-method: hvr-ppa
3852
allow-failure: false
3953
- compiler: ghc-8.6.5
54+
compilerKind: ghc
55+
compilerVersion: 8.6.5
56+
setup-method: hvr-ppa
4057
allow-failure: false
4158
- compiler: ghc-8.4.4
59+
compilerKind: ghc
60+
compilerVersion: 8.4.4
61+
setup-method: hvr-ppa
4262
allow-failure: false
4363
- compiler: ghc-8.2.2
64+
compilerKind: ghc
65+
compilerVersion: 8.2.2
66+
setup-method: hvr-ppa
4467
allow-failure: false
4568
- compiler: ghc-8.0.2
69+
compilerKind: ghc
70+
compilerVersion: 8.0.2
71+
setup-method: hvr-ppa
4672
allow-failure: false
4773
- compiler: ghc-7.10.3
74+
compilerKind: ghc
75+
compilerVersion: 7.10.3
76+
setup-method: hvr-ppa
4877
allow-failure: false
4978
- compiler: ghc-7.8.4
79+
compilerKind: ghc
80+
compilerVersion: 7.8.4
81+
setup-method: hvr-ppa
5082
allow-failure: false
5183
- compiler: ghc-7.6.3
84+
compilerKind: ghc
85+
compilerVersion: 7.6.3
86+
setup-method: hvr-ppa
5287
allow-failure: false
5388
fail-fast: false
5489
steps:
5590
- name: apt
5691
run: |
5792
apt-get update
58-
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common
59-
apt-add-repository -y 'ppa:hvr/ghc'
60-
apt-get update
61-
apt-get install -y $CC cabal-install-3.4
93+
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
94+
if [ "${{ matrix.setup-method }}" = ghcup ]; then
95+
mkdir -p "$HOME/.ghcup/bin"
96+
curl -sL https://downloads.haskell.org/ghcup/0.1.17.3/x86_64-linux-ghcup-0.1.17.3 > "$HOME/.ghcup/bin/ghcup"
97+
chmod a+x "$HOME/.ghcup/bin/ghcup"
98+
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER"
99+
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0
100+
else
101+
apt-add-repository -y 'ppa:hvr/ghc'
102+
apt-get update
103+
apt-get install -y "$HCNAME"
104+
mkdir -p "$HOME/.ghcup/bin"
105+
curl -sL https://downloads.haskell.org/ghcup/0.1.17.3/x86_64-linux-ghcup-0.1.17.3 > "$HOME/.ghcup/bin/ghcup"
106+
chmod a+x "$HOME/.ghcup/bin/ghcup"
107+
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0
108+
fi
62109
env:
63-
CC: ${{ matrix.compiler }}
110+
HCKIND: ${{ matrix.compilerKind }}
111+
HCNAME: ${{ matrix.compiler }}
112+
HCVER: ${{ matrix.compilerVersion }}
64113
- name: Set PATH and environment variables
65114
run: |
66115
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
67-
echo "LANG=C.UTF-8" >> $GITHUB_ENV
68-
echo "CABAL_DIR=$HOME/.cabal" >> $GITHUB_ENV
69-
echo "CABAL_CONFIG=$HOME/.cabal/config" >> $GITHUB_ENV
70-
HCDIR=$(echo "/opt/$CC" | sed 's/-/\//')
71-
HCNAME=ghc
72-
HC=$HCDIR/bin/$HCNAME
73-
echo "HC=$HC" >> $GITHUB_ENV
74-
echo "HCPKG=$HCDIR/bin/$HCNAME-pkg" >> $GITHUB_ENV
75-
echo "HADDOCK=$HCDIR/bin/haddock" >> $GITHUB_ENV
76-
echo "CABAL=/opt/cabal/3.4/bin/cabal -vnormal+nowrap" >> $GITHUB_ENV
116+
echo "LANG=C.UTF-8" >> "$GITHUB_ENV"
117+
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
118+
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
119+
HCDIR=/opt/$HCKIND/$HCVER
120+
if [ "${{ matrix.setup-method }}" = ghcup ]; then
121+
HC=$HOME/.ghcup/bin/$HCKIND-$HCVER
122+
echo "HC=$HC" >> "$GITHUB_ENV"
123+
echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV"
124+
echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV"
125+
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
126+
else
127+
HC=$HCDIR/bin/$HCKIND
128+
echo "HC=$HC" >> "$GITHUB_ENV"
129+
echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV"
130+
echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV"
131+
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
132+
fi
133+
77134
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
78-
echo "HCNUMVER=$HCNUMVER" >> $GITHUB_ENV
79-
echo "ARG_TESTS=--enable-tests" >> $GITHUB_ENV
80-
echo "ARG_BENCH=--enable-benchmarks" >> $GITHUB_ENV
81-
echo "HEADHACKAGE=false" >> $GITHUB_ENV
82-
echo "ARG_COMPILER=--$HCNAME --with-compiler=$HC" >> $GITHUB_ENV
83-
echo "GHCJSARITH=0" >> $GITHUB_ENV
135+
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
136+
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
137+
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV"
138+
echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
139+
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
140+
echo "GHCJSARITH=0" >> "$GITHUB_ENV"
84141
env:
85-
CC: ${{ matrix.compiler }}
142+
HCKIND: ${{ matrix.compilerKind }}
143+
HCNAME: ${{ matrix.compiler }}
144+
HCVER: ${{ matrix.compilerVersion }}
86145
- name: env
87146
run: |
88147
env
@@ -117,7 +176,7 @@ jobs:
117176
- name: cache (tools)
118177
uses: actions/cache@v2
119178
with:
120-
key: ${{ runner.os }}-${{ matrix.compiler }}-tools-7e5c568c
179+
key: ${{ runner.os }}-${{ matrix.compiler }}-tools-a12dda74
121180
path: ~/.haskell-ci-tools
122181
- name: install cabal-plan
123182
run: |
@@ -161,7 +220,8 @@ jobs:
161220
- name: generate cabal.project
162221
run: |
163222
PKGDIR_lattices="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/lattices-[0-9.]*')"
164-
echo "PKGDIR_lattices=${PKGDIR_lattices}" >> $GITHUB_ENV
223+
echo "PKGDIR_lattices=${PKGDIR_lattices}" >> "$GITHUB_ENV"
224+
rm -f cabal.project cabal.project.local
165225
touch cabal.project
166226
touch cabal.project.local
167227
echo "packages: ${PKGDIR_lattices}" >> cabal.project

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.0.3 (2021-10-30)
2+
3+
- Add instances for `Solo`
4+
15
# 2.0.2 (2020-02-18)
26

37
- Add `Algebra.Lattice.Stacked`

lattices.cabal

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cabal-version: 1.18
22
name: lattices
3-
version: 2.0.2
4-
x-revision: 4
3+
version: 2.0.3
54
category: Math
65
license: BSD3
76
license-file: LICENSE
@@ -33,6 +32,7 @@ tested-with:
3332
|| ==8.8.3
3433
|| ==8.10.4
3534
|| ==9.0.1
35+
|| ==9.2.1
3636

3737
synopsis:
3838
Fine-grained library for constructing and manipulating lattices
@@ -82,7 +82,7 @@ library
8282
Algebra.PartialOrd.Instances
8383

8484
build-depends:
85-
base >=4.6 && <4.16
85+
base >=4.6 && <4.17
8686
, base-compat >=0.10.5 && <0.13
8787
, containers >=0.5.0.0 && <0.7
8888
, deepseq >=1.3.0.0 && <1.5
@@ -96,6 +96,12 @@ library
9696
, universe-reverse-instances >=1.1 && <1.2
9797
, unordered-containers >=0.2.8.0 && <0.3
9898

99+
if !impl(ghc >=9.2)
100+
if impl(ghc >=9.0)
101+
build-depends: ghc-prim
102+
else
103+
build-depends: OneTuple >=0.3 && <0.4
104+
99105
if !impl(ghc >=8.0)
100106
build-depends: semigroups >=0.18.5 && <0.20
101107

src/Algebra/Heyting.hs

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE ConstraintKinds #-}
23
{-# LANGUAGE Safe #-}
34
----------------------------------------------------------------------------
@@ -26,6 +27,14 @@ import Data.Universe.Class (Finite (..))
2627
import qualified Data.HashSet as HS
2728
import qualified Data.Set as Set
2829

30+
#if MIN_VERSION_base(4,16,0)
31+
import Data.Tuple (Solo (..))
32+
#elif MIN_VERSION_base(4,15,0)
33+
import GHC.Tuple (Solo (..))
34+
#else
35+
import Data.Tuple.Solo (Solo (..))
36+
#endif
37+
2938
-- | A Heyting algebra is a bounded lattice equipped with a
3039
-- binary operation \(a \to b\) of implication.
3140
--
@@ -101,7 +110,7 @@ instance Heyting a => Heyting (Endo a) where
101110
Endo a <=> Endo b = Endo (a <=> b)
102111

103112
-------------------------------------------------------------------------------
104-
-- Proxy, Tagged, Const, Identity
113+
-- Proxy, Tagged, Const, Identity, Solo
105114
-------------------------------------------------------------------------------
106115

107116
instance Heyting (Proxy a) where
@@ -124,6 +133,12 @@ instance Heyting a => Heyting (Const a b) where
124133
neg (Const a) = Const (neg a)
125134
Const a <=> Const b = Const (a <=> b)
126135

136+
-- | @since 2.0.3
137+
instance Heyting a => Heyting (Solo a) where
138+
Solo a ==> Solo b = Solo (a ==> b)
139+
neg (Solo a) = Solo (neg a)
140+
Solo a <=> Solo b = Solo (a <=> b)
141+
127142
-------------------------------------------------------------------------------
128143
-- Sets
129144
-------------------------------------------------------------------------------

src/Algebra/Lattice.hs

+26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE ConstraintKinds #-}
23
{-# LANGUAGE DeriveDataTypeable #-}
34
{-# LANGUAGE DeriveGeneric #-}
@@ -65,6 +66,14 @@ import qualified Data.Map as Map
6566
import qualified Data.Set as Set
6667
import qualified Test.QuickCheck as QC
6768

69+
#if MIN_VERSION_base(4,16,0)
70+
import Data.Tuple (Solo (..))
71+
#elif MIN_VERSION_base(4,15,0)
72+
import GHC.Tuple (Solo (..))
73+
#else
74+
import Data.Tuple.Solo (Solo (..))
75+
#endif
76+
6877
infixr 6 /\ -- This comment needed because of CPP
6978
infixr 5 \/
7079

@@ -488,6 +497,23 @@ instance Lattice QC.Property where
488497
instance BoundedJoinSemiLattice QC.Property where bottom = QC.property False
489498
instance BoundedMeetSemiLattice QC.Property where top = QC.property True
490499

500+
-------------------------------------------------------------------------------
501+
-- OneTuple
502+
-------------------------------------------------------------------------------
503+
504+
-- | @since 2.0.3
505+
instance Lattice a => Lattice (Solo a) where
506+
Solo a \/ Solo b = Solo (a \/ b)
507+
Solo a /\ Solo b = Solo (a /\ b)
508+
509+
-- | @since 2.0.3
510+
instance BoundedMeetSemiLattice a => BoundedMeetSemiLattice (Solo a) where
511+
top = Solo top
512+
513+
-- | @since 2.0.3
514+
instance BoundedJoinSemiLattice a => BoundedJoinSemiLattice (Solo a) where
515+
bottom = Solo bottom
516+
491517
-------------------------------------------------------------------------------
492518
-- Theorems
493519
-------------------------------------------------------------------------------

0 commit comments

Comments
 (0)