packages feed

OneTuple 0.2.2 → 0.2.2.1

raw patch · 4 files changed

+127/−118 lines, 4 filesdep ~basePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: base

API changes (from Hackage documentation)

- Data.Tuple.OneTuple: instance Data.Semigroup.Semigroup a => Data.Semigroup.Semigroup (Data.Tuple.OneTuple.OneTuple a)
+ Data.Tuple.OneTuple: instance GHC.Base.Semigroup a => GHC.Base.Semigroup (Data.Tuple.OneTuple.OneTuple a)

Files

Changelog.md view
@@ -1,3 +1,7 @@+# next++- Compatible with GHC-8.6+ # 0.2.2  - Add `Semigroup` instances
− Data/Tuple/OneTuple.hs
@@ -1,85 +0,0 @@--- |OneTuple fills the /tuple gap/ with a singleton tuple.--- --- OneTuple /does not support/ the usual parenthesized tuple syntax.--- --- OneTuple------   * has the expected laziness properties------   * can be pattern-matched------   * ships with instances for several standard type classes,---     including all those supported by H98-standard tuples------   * requires no language extensions, except for hierarchical modules--module Data.Tuple.OneTuple (OneTuple(OneTuple), only) where--import Control.Applicative (Applicative (..), liftA)-import Control.Monad (ap)-import Control.Monad.Fix (MonadFix (..))-import Data.Foldable (Foldable (..))-import Data.Ix (Ix (..))-import Data.Monoid (Monoid (..))-import Data.Semigroup (Semigroup (..))-import Data.Traversable (Traversable (..))---- |OneTuple is the singleton tuple data type.-data OneTuple a-    = OneTuple a  -- ^ singleton tuple constructor-    deriving (Eq,Ord,Bounded,Show,Read)---- |The 'only' function extracts the OneTuple's only member.--- (Compare to 'fst' and 'snd'.)-only :: OneTuple a -- ^ takes a singleton tuple argument-     -> a          -- ^ returns the only element in the tuple-only (OneTuple x) = x--instance (Enum a) => Enum (OneTuple a) where-    succ = liftA succ-    pred = liftA pred-    toEnum = pure . toEnum-    fromEnum (OneTuple x) = fromEnum x--instance (Ix a) => Ix (OneTuple a) where-    range   (OneTuple x, OneTuple y) = map OneTuple (range (x,y))-    index   (OneTuple x, OneTuple y) (OneTuple z) = index   (x,y) z-    inRange (OneTuple x, OneTuple y) (OneTuple z) = inRange (x,y) z--instance Foldable OneTuple where-    fold (OneTuple m) = m-    foldMap f (OneTuple x) = f x-    foldr f b (OneTuple x) = f x b-    foldl f a (OneTuple x) = f a x-    foldr1 _f (OneTuple x) = x-    foldl1 _f (OneTuple x) = x--instance Traversable OneTuple where-    traverse f (OneTuple x) = fmap OneTuple (f x)-    sequenceA (OneTuple x) = fmap OneTuple x--instance Functor OneTuple where-    fmap f (OneTuple x) = OneTuple (f x)--instance Applicative OneTuple where-    pure = OneTuple--    OneTuple f <*> OneTuple x = OneTuple (f x)-    _ *> x = x-    x <* _ = x--instance Monad OneTuple where-    return = pure-    (>>) = (*>)-    (OneTuple x) >>= f = f x--instance (Semigroup a) => Semigroup (OneTuple a) where-    OneTuple x <> OneTuple y = OneTuple (x <> y)--instance (Monoid a) => Monoid (OneTuple a) where-    mempty = OneTuple mempty-    mappend (OneTuple x) (OneTuple y) = OneTuple (mappend x y)--instance MonadFix OneTuple where-    mfix f = let a = f (only a) in a-
OneTuple.cabal view
@@ -1,44 +1,49 @@-cabal-version:   >=1.10-Name:            OneTuple-Version:         0.2.2--Synopsis:        Singleton Tuple-Category:        Data-Description:+cabal-version:      >=1.10+name:               OneTuple+version:            0.2.2.1+synopsis:           Singleton Tuple+category:           Data+description:   This package provides a singleton tuple data type   .-  > data OneTuple = OneTuple a+  > data OneTuple a = OneTuple a   .   Note: it's not a @newtype@-Copyright:       (c) John Dorsey 2008-License:	 BSD3-License-file:    LICENSE-Author:          John Dorsey <haskell@colquitt.org>-Maintainer:      Oleg Grenrus <oleg.grenrus@iki.fi>, John Dorsey <haskell@colquitt.org>-Stability:       experimental-Build-type:      Simple++copyright:          (c) John Dorsey 2008+license:            BSD3+license-file:       LICENSE+author:             John Dorsey <haskell@colquitt.org>+maintainer:+  Oleg Grenrus <oleg.grenrus@iki.fi>, John Dorsey <haskell@colquitt.org>++stability:          experimental+build-type:         Simple tested-with:-  GHC  ==7.0.4-    || ==7.2.2-    || ==7.4.2-    || ==7.6.3-    || ==7.8.4-    || ==7.10.3-    || ==8.0.2-    || ==8.2.2-    || ==8.4.2-extra-source-files:-  Changelog.md+  GHC ==7.0.4+   || ==7.2.2+   || ==7.4.2+   || ==7.6.3+   || ==7.8.4+   || ==7.10.3+   || ==8.0.2+   || ==8.2.2+   || ==8.4.4+   || ==8.6.5+   || ==8.8.3+   || ==8.10.1 +extra-source-files: Changelog.md+ source-repository head-  type:      git-  location:  https://github.com/phadej/OneTUple.git+  type:     git+  location: https://github.com/phadej/OneTuple.git  library   default-language: Haskell98-  Exposed-Modules:  Data.Tuple.OneTuple-  Build-depends:    base >= 4.3 && <4.12--  if !impl(ghc >= 8.0)-    Build-depends:  semigroups >=0.18.4 && <0.19+  exposed-modules:  Data.Tuple.OneTuple+  hs-source-dirs:   src+  build-depends:    base >=4.3 && <4.15 +  if !impl(ghc >=8.0)+    build-depends: semigroups >=0.18.4 && <0.20
+ src/Data/Tuple/OneTuple.hs view
@@ -0,0 +1,85 @@+-- |OneTuple fills the /tuple gap/ with a singleton tuple.+--+-- OneTuple /does not support/ the usual parenthesized tuple syntax.+--+-- OneTuple+--+--   * has the expected laziness properties+--+--   * can be pattern-matched+--+--   * ships with instances for several standard type classes,+--     including all those supported by H98-standard tuples+--+--   * requires no language extensions, except for hierarchical modules++module Data.Tuple.OneTuple (OneTuple(OneTuple), only) where++import Control.Applicative (Applicative (..))+import Control.Monad       (ap)+import Control.Monad.Fix   (MonadFix (..))+import Data.Foldable       (Foldable (..))+import Data.Ix             (Ix (..))+import Data.Monoid         (Monoid (..))+import Data.Semigroup      (Semigroup (..))+import Data.Traversable    (Traversable (..))++-- |OneTuple is the singleton tuple data type.+data OneTuple a+    = OneTuple a  -- ^ singleton tuple constructor+    deriving (Eq,Ord,Bounded,Show,Read)++-- |The 'only' function extracts the OneTuple's only member.+-- (Compare to 'fst' and 'snd'.)+only :: OneTuple a -- ^ takes a singleton tuple argument+     -> a          -- ^ returns the only element in the tuple+only (OneTuple x) = x++instance (Enum a) => Enum (OneTuple a) where+    succ = fmap succ+    pred = fmap pred+    toEnum = pure . toEnum+    fromEnum (OneTuple x) = fromEnum x++instance (Ix a) => Ix (OneTuple a) where+    range   (OneTuple x, OneTuple y) = map OneTuple (range (x,y))+    index   (OneTuple x, OneTuple y) (OneTuple z) = index   (x,y) z+    inRange (OneTuple x, OneTuple y) (OneTuple z) = inRange (x,y) z++instance Foldable OneTuple where+    fold (OneTuple m) = m+    foldMap f (OneTuple x) = f x+    foldr f b (OneTuple x) = f x b+    foldl f a (OneTuple x) = f a x+    foldr1 _f (OneTuple x) = x+    foldl1 _f (OneTuple x) = x++instance Traversable OneTuple where+    traverse f (OneTuple x) = fmap OneTuple (f x)+    sequenceA (OneTuple x) = fmap OneTuple x++instance Functor OneTuple where+    fmap f (OneTuple x) = OneTuple (f x)++instance Applicative OneTuple where+    pure = OneTuple++    OneTuple f <*> OneTuple x = OneTuple (f x)+    _ *> x = x+    x <* _ = x++instance Monad OneTuple where+    return = pure+    (>>) = (*>)+    (OneTuple x) >>= f = f x++instance (Semigroup a) => Semigroup (OneTuple a) where+    OneTuple x <> OneTuple y = OneTuple (x <> y)++instance (Monoid a) => Monoid (OneTuple a) where+    mempty = OneTuple mempty+    mappend (OneTuple x) (OneTuple y) = OneTuple (mappend x y)++instance MonadFix OneTuple where+    mfix f = let a = f (only a) in a+