Skip to content

Commit 42022bc

Browse files
committed
basic mhs compatibility
1 parent bc0a3e2 commit 42022bc

3 files changed

Lines changed: 27 additions & 7 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
dist-newstyle
2+
dist-mcabal
23
.ghc.environment.*
34
cabal.project.local

OneTuple.cabal

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,26 @@ library
4545
exposed-modules:
4646
Data.Tuple.OneTuple
4747
Data.Tuple.Solo
48-
Data.Tuple.Solo.TH
48+
49+
if impl(ghc)
50+
exposed-modules:
51+
Data.Tuple.Solo.TH
52+
build-depends:
53+
template-haskell
4954

5055
hs-source-dirs: src
5156
build-depends:
5257
base >=4.12 && <4.23
53-
, template-haskell
5458

5559
if impl(ghc >=9.0)
5660
build-depends: ghc-prim
5761
else
5862
build-depends: hashable >=1.3.5.0 && <1.6
5963

60-
if !impl(ghc >=9.0)
64+
if impl(ghc) && !impl(ghc >=9.0)
6165
build-depends: foldable1-classes-compat >=0.1 && <0.2
6266

63-
if !impl(ghc >=9.2)
67+
if impl(ghc) && !impl(ghc >=9.2)
6468
build-depends: base-orphans >=0.8.6
6569

6670
test-suite instances
@@ -73,13 +77,13 @@ test-suite instances
7377
, hashable
7478
, OneTuple
7579

76-
if !impl(ghc >=8.0)
80+
if impl(ghc) && !impl(ghc >=8.0)
7781
build-depends:
7882
semigroups
7983
, transformers
8084
, transformers-compat
8185

82-
if !impl(ghc >=9.6)
86+
if impl(ghc) && !impl(ghc >=9.6)
8387
build-depends: foldable1-classes-compat >=0.1 && <0.2
8488

8589
test-suite th

src/Data/Tuple/Solo.hs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,22 @@ module Data.Tuple.Solo (
3030
import Data.Orphans ()
3131
#endif
3232

33-
#if MIN_VERSION_base(4,18,0)
33+
#if defined(__MHS__)
34+
import Data.Tuple (Solo (MkSolo), getSolo)
35+
36+
pattern Solo :: a -> Solo a
37+
pattern Solo a = Solo a
38+
39+
{-# COMPLETE Solo #-}
40+
41+
instance (Enum a) => Enum (Solo a) where
42+
succ = fmap succ
43+
pred = fmap pred
44+
toEnum = pure . toEnum
45+
fromEnum (MkSolo x) = fromEnum x
46+
47+
48+
#elif MIN_VERSION_base(4,18,0)
3449
import GHC.Tuple (Solo (MkSolo, Solo), getSolo)
3550

3651

0 commit comments

Comments
 (0)