packages feed

NonEmptyList 0.0.1 → 0.0.2

raw patch · 3 files changed

+54/−13 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Data.List.NonEmpty: repeat :: a -> NonEmpty a
- Data.List.NonEmpty: zip :: NonEmpty a -> NonEmpty b -> NonEmpty (a, b)
+ Data.List.ZipNonEmpty: data ZipNonEmpty a
+ Data.List.ZipNonEmpty: instance (Eq a) => Eq (ZipNonEmpty a)
+ Data.List.ZipNonEmpty: instance (Ord a) => Ord (ZipNonEmpty a)
+ Data.List.ZipNonEmpty: instance (Show a) => Show (ZipNonEmpty a)
+ Data.List.ZipNonEmpty: instance Applicative ZipNonEmpty
+ Data.List.ZipNonEmpty: instance Functor ZipNonEmpty
+ Data.List.ZipNonEmpty: ne :: ZipNonEmpty a -> NonEmpty a
+ Data.List.ZipNonEmpty: usingNe :: (NonEmpty a -> NonEmpty b) -> ZipNonEmpty a -> ZipNonEmpty b
+ Data.List.ZipNonEmpty: usingZne :: (ZipNonEmpty a -> ZipNonEmpty b) -> NonEmpty a -> NonEmpty b
+ Data.List.ZipNonEmpty: zipNe :: NonEmpty a -> ZipNonEmpty a

Files

Data/List/NonEmpty.hs view
@@ -18,13 +18,11 @@                            scanr,                            scanr1,                            iterate,-                           repeat,                            cycle,                            inits,                            tails,                            sort,                            insert,-                           zip,                            unzip,                                                       -- * Tests                            prop_neHead,@@ -145,10 +143,6 @@            -> NonEmpty a iterate = (unsafeToNonEmpty .) . L.iterate -repeat :: a-          -> NonEmpty a-repeat = unsafeToNonEmpty . L.repeat- cycle :: (Foldable f) =>          f a          -> NonEmpty a@@ -172,11 +166,6 @@           NonEmpty a ->           NonEmpty a insert a = unsafeToNonEmpty . L.insert a . toList--zip :: NonEmpty a ->-       NonEmpty b ->-       NonEmpty (a, b)-zip a b = unsafeToNonEmpty (L.zip (toList a) (toList b))  unzip :: NonEmpty (a, b) ->          (NonEmpty a, NonEmpty b)
+ Data/List/ZipNonEmpty.hs view
@@ -0,0 +1,51 @@+-- | A wrapper of @NonEmpty@ that has a zip-like @Applicative@ instance.+module Data.List.ZipNonEmpty(+                              ZipNonEmpty,+                              -- * Accessors+                              ne,+                              zipNe,+                              -- * Combinators+                              usingNe,+                              usingZne+                            ) where++import Data.List+import Data.Foldable+import Data.List.NonEmpty+import Control.Applicative++-- | A wrapper of @NonEmpty@ that has a zip-like @Applicative@ instance.+newtype ZipNonEmpty a = Z {+  -- | Unwraps a zip-like non-empty list.+  ne :: NonEmpty a+} deriving (Eq, Ord)++-- | Wraps a non-empty list.+zipNe :: NonEmpty a ->+         ZipNonEmpty a+zipNe = Z++-- | Runs a function for non-empty lists on zip-like non-empty lists.+usingNe :: (NonEmpty a ->+           NonEmpty b) ->+           ZipNonEmpty a ->+           ZipNonEmpty b+usingNe = (zipNe .) . (. ne)++-- | Runs a function for zip-like non-empty lists on non-empty lists.+usingZne :: (ZipNonEmpty a ->+            ZipNonEmpty b) ->+            NonEmpty a ->+            NonEmpty b+usingZne = (ne .) . (. zipNe)++instance (Show a) => Show (ZipNonEmpty a) where+  show = show . ne++instance Functor ZipNonEmpty where+  fmap = usingNe . fmap++instance Applicative ZipNonEmpty where+  pure = zipNe . unsafeToNonEmpty . repeat+  f <*> a = let z = toList . ne+            in zipNe . unsafeToNonEmpty $ zipWith id (z f) (z a)
NonEmptyList.cabal view
@@ -1,5 +1,5 @@ Name:                NonEmptyList-Version:             0.0.1+Version:             0.0.2 License:             BSD3 License-File:        LICENSE Synopsis:            A list with a length of at least one.@@ -8,7 +8,7 @@ Category:            Data Author:              Tony Morris, Oliver Taylor Maintainer:          code@tmorris.net-Copyright:           2010 Tony Morris+Copyright:           2010 Tony Morris, Oliver Taylor build-type:          Simple cabal-version:       >= 1.2 @@ -23,3 +23,4 @@    GHC-Options:    -Wall   Exposed-Modules: Data.List.NonEmpty+                   Data.List.ZipNonEmpty