single-tuple 0.1.2.0 → 0.1.3.0
raw patch · 4 files changed
+80/−26 lines, 4 filesdep ~OneTupledep ~ghc-primdep ~hspec
Dependency ranges changed: OneTuple, ghc-prim, hspec
Files
- ChangeLog.md +6/−0
- single-tuple.cabal +21/−22
- src/Data/Tuple/Single.hs +28/−3
- test/Data/Tuple/SingleSpec.hs +25/−1
ChangeLog.md view
@@ -1,5 +1,11 @@ # Changelog for single-tuple +## 0.1.3.0++2023.08.17++Support [OneTuple](https://hackage.haskell.org/package/OneTuple) 0.3, 0.4.+ ## 0.1.2.0 2021.05.21
single-tuple.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2 name: single-tuple-version: 0.1.2.0+version: 0.1.3.0 synopsis: a class for single tuple implementations description: a class for single tuple implementations category: Data@@ -14,7 +14,7 @@ license-file: LICENSE build-type: Simple -extra-source-files:+extra-doc-files: README.md ChangeLog.md @@ -23,32 +23,31 @@ location: https://github.com/kakkun61/tuple common common- build-depends: base >=4.10 && <5,- OneTuple >=0.2 && <0.3,- Only >=0.1 && <0.2,- ghc-prim- ghc-options: -Wall- -Wcompat- -Wincomplete-uni-patterns- -Wincomplete-record-updates- -Wmonomorphism-restriction- -Wmissing-exported-signatures- -Wmissing-home-modules- -Wmissing-import-lists- -Widentities- -Wredundant-constraints- -Wno-name-shadowing- -Wno-unticked-promoted-constructors+ build-depends: base >=4.10 && <5,+ OneTuple >=0.2 && <0.5,+ Only >=0.1 && <0.2,+ ghc-prim >= 0.5 && < 0.9+ ghc-options: -Wall+ -Wcompat+ -Wincomplete-uni-patterns+ -Wincomplete-record-updates+ -Wmonomorphism-restriction+ -Wmissing-exported-signatures+ -Wmissing-home-modules+ -Widentities+ -Wredundant-constraints+ -Wno-name-shadowing+ -Wno-unticked-promoted-constructors if impl(ghc >= 8.4.0)- ghc-options: -Wpartial-fields+ ghc-options: -Wmissing-export-lists+ -Wpartial-fields default-language: Haskell2010 library import: common exposed-modules: Data.Tuple.Single hs-source-dirs: src- if impl(ghc >= 8.4.0)- ghc-options: -Wmissing-export-lists+ ghc-options: -Wmissing-import-lists test-suite test import: common@@ -61,5 +60,5 @@ -with-rtsopts=-N -Wno-missing-import-lists build-depends: single-tuple,- hspec+ hspec >=2.11 && <2.12 build-tool-depends: hspec-discover:hspec-discover
src/Data/Tuple/Single.hs view
@@ -20,10 +20,19 @@ ) where import Data.Functor.Identity (Identity (Identity, runIdentity))-import Data.Tuple.OneTuple (OneTuple (OneTuple), only) import Data.Tuple.Only (Only (Only, fromOnly)) -#if MIN_VERSION_ghc_prim(0,7,0)+#if MIN_VERSION_OneTuple(0,3,0)+#if !MIN_VERSION_base(4,15,0)+import qualified Data.Tuple.Solo as OneTuple+#endif+#else+import Data.Tuple.OneTuple (OneTuple (OneTuple), only)+#endif++#if MIN_VERSION_ghc_prim(0,10,0)+import GHC.Tuple (Solo (MkSolo))+#elif MIN_VERSION_ghc_prim(0,7,0) import GHC.Tuple (Solo (Solo)) #else import GHC.Tuple (Unit (Unit))@@ -49,13 +58,29 @@ {-# COMPLETE Single :: Only #-} +#if MIN_VERSION_OneTuple(0,3,0)+#if !MIN_VERSION_base(4,15,0)+instance Single OneTuple.Solo where+ wrap = OneTuple.Solo+ unwrap = OneTuple.getSolo++{-# COMPLETE Single :: OneTuple.Solo #-}+#endif+#else instance Single OneTuple where wrap = OneTuple unwrap = only {-# COMPLETE Single :: OneTuple #-}+#endif -#if MIN_VERSION_ghc_prim(0,7,0)+#if MIN_VERSION_ghc_prim(0,10,0)+instance Single Solo where+ wrap = MkSolo+ unwrap (MkSolo a) = a++{-# COMPLETE Single :: Solo #-}+#elif MIN_VERSION_ghc_prim(0,7,0) instance Single Solo where wrap = Solo unwrap (Solo a) = a
test/Data/Tuple/SingleSpec.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} module Data.Tuple.SingleSpec (spec) where import Data.Tuple.Single@@ -5,9 +6,16 @@ import Test.Hspec import Data.Functor.Identity-import Data.Tuple.OneTuple import Data.Tuple.Only +#if MIN_VERSION_OneTuple(0,3,0)+#if !MIN_VERSION_base(4,15,0)+import qualified Data.Tuple.Solo as OneTuple+#endif+#else+import Data.Tuple.OneTuple+#endif+ spec :: Spec spec = do describe "Identity" $ do@@ -34,6 +42,21 @@ let Single a = Single () :: Only () a `shouldBe` () +#if MIN_VERSION_OneTuple(0,3,0)+#if !MIN_VERSION_base(4,15,0)+ describe "OneTuple.Solo" $ do+ it "unwrap . wrap" $ do+ unwrap (wrap () :: OneTuple.Solo ()) `shouldBe` ()++ it "wrap . unwrap" $ do+ let a = OneTuple.Solo ()+ wrap (unwrap a) `shouldBe` a++ it "pattern destruct construct" $ do+ let Single a = Single () :: OneTuple.Solo ()+ a `shouldBe` ()+#endif+#else describe "OneTuple" $ do it "unwrap . wrap" $ do unwrap (wrap () :: OneTuple ()) `shouldBe` ()@@ -45,3 +68,4 @@ it "pattern destruct construct" $ do let Single a = Single () :: OneTuple () a `shouldBe` ()+#endif