non-empty 0.1.2 → 0.1.3
raw patch · 6 files changed
+48/−26 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Empty: instance Repeat T
+ Data.Zip: Cons :: f a -> T f a
+ Data.Zip: decons :: T f a -> f a
+ Data.Zip: instance (Zip f, Repeat f) => Applicative (T f)
+ Data.Zip: instance Functor f => Functor (T f)
+ Data.Zip: newtype T f a
+ Data.Zip: transposeClip :: (Traversable f, Zip g, Repeat g) => f (g a) -> g (f a)
Files
- non-empty.cabal +3/−2
- src/Data/Empty.hs +6/−0
- src/Data/NonEmpty.hs +2/−1
- src/Data/NonEmpty/Class.hs +5/−0
- src/Data/NonEmptyPrivate.hs +0/−23
- src/Data/Zip.hs +32/−0
non-empty.cabal view
@@ -1,5 +1,5 @@ Name: non-empty-Version: 0.1.2+Version: 0.1.3 License: BSD3 License-File: LICENSE Author: Henning Thielemann <haskell@henning-thielemann.de>@@ -57,7 +57,7 @@ Build-Type: Simple Source-Repository this- Tag: 0.1.2+ Tag: 0.1.3 Type: darcs Location: http://code.haskell.org/~thielema/non-empty @@ -80,5 +80,6 @@ Data.NonEmpty.Mixed Data.Empty Data.Optional+ Data.Zip Other-Modules: Data.NonEmptyPrivate
src/Data/Empty.hs view
@@ -44,3 +44,9 @@ instance C.Sort T where sortBy _ Cons = Cons++{-+This instance allows us to use @transposeClip@ on fixed sized containers.+-}+instance C.Repeat T where+ repeat _ = Cons
src/Data/NonEmpty.hs view
@@ -26,10 +26,11 @@ sortBy, sort, Insert(insertBy), insert, scanl, scanr,- transposeClip,+ Zip.transposeClip, Tails(tails), RemoveEach(removeEach), ) where +import qualified Data.Zip as Zip import Data.NonEmptyPrivate import Prelude ()
src/Data/NonEmpty/Class.hs view
@@ -112,6 +112,11 @@ class Repeat f where+ {- |+ Create a container with as many copies as possible of a given value.+ That is, for a container with fixed size @n@,+ the call @repeat x@ will generate a container with @n@ copies of @x@.+ -} repeat :: a -> f a instance Repeat [] where
src/Data/NonEmptyPrivate.hs view
@@ -446,29 +446,6 @@ xss -> cons (C.cons x $ head xss) xss -newtype Zip f a = Zip {unZip :: f a}--instance Functor f => Functor (Zip f) where- fmap f (Zip xs) = Zip $ fmap f xs--instance (C.Zip f, C.Repeat f) => Applicative (Zip f) where- pure a = Zip $ C.repeat a- Zip f <*> Zip x = Zip $ C.zipWith ($) f x----{- |-Always returns a rectangular list-by clipping all dimensions to the shortest slice.-Be aware that @transpose [] == repeat []@.--}-transposeClip ::- (Traversable f, C.Zip g, C.Repeat g) =>- f (g a) -> g (f a)-transposeClip =- unZip . Trav.sequenceA . fmap Zip-- {- Not exorted by NonEmpty. I think the transposeClip function is better.
+ src/Data/Zip.hs view
@@ -0,0 +1,32 @@+module Data.Zip where++import qualified Data.NonEmpty.Class as C++import qualified Data.Traversable as Trav+import Data.Traversable (Traversable, )+import Control.Applicative (Applicative, pure, (<*>), )+++{- |+Wrap a container such that its Applicative instance is based on zip.+-}+newtype T f a = Cons {decons :: f a}++instance Functor f => Functor (T f) where+ fmap f (Cons xs) = Cons $ fmap f xs++instance (C.Zip f, C.Repeat f) => Applicative (T f) where+ pure a = Cons $ C.repeat a+ Cons f <*> Cons x = Cons $ C.zipWith ($) f x+++{- |+Always returns a rectangular list+by clipping all dimensions to the shortest slice.+Be aware that @transpose [] == repeat []@.+-}+transposeClip ::+ (Traversable f, C.Zip g, C.Repeat g) =>+ f (g a) -> g (f a)+transposeClip =+ decons . Trav.sequenceA . fmap Cons