packages feed

NonEmptyList 0.0.4 → 0.0.5

raw patch · 2 files changed

+9/−15 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Data/List/NonEmpty.hs view
@@ -66,25 +66,19 @@ instance Monad NonEmpty where   return = flip NonEmpty []   NonEmpty h t >>= f = let NonEmpty a b = f h-                           k = t >>= fromNonEmpty . f+                           k = t >>= toList . f                        in NonEmpty a (b ++ k)  instance Foldable NonEmpty where-  foldr f x (NonEmpty h t) = foldr f x (h:t)+  foldr f x (NonEmpty h t) = f h (foldr f x t)   foldl f x (NonEmpty h t) = foldl' f x (h:t)  instance Traversable NonEmpty where-  traverse f a = NonEmpty <$> head <*> tail <$> traverse f (fromNonEmpty a)+  traverse f a = NonEmpty <$> head <*> tail <$> traverse f (toList a)  instance (Show a) => Show (NonEmpty a) where   show (NonEmpty h t) = '|' : show (h:t) ++ "|" --- | Conversion to ordinary list (like Data.Foldable.toList, but O(1)).-fromNonEmpty :: NonEmpty a -> [a]-fromNonEmpty (NonEmpty x y) = x : y--{-# RULES "toList/fromNonEmpty" toList = fromNonEmpty #-}- -- | Constructs a non-empty list with the given head and tail. nonEmpty :: a -- ^ The head.             -> [a] -- ^ The tail.@@ -175,11 +169,11 @@           a ->           NonEmpty a ->           NonEmpty a-insert a = unsafeToNonEmpty . L.insert a . fromNonEmpty+insert a = unsafeToNonEmpty . L.insert a . toList  unzip :: NonEmpty (a, b) ->          (NonEmpty a, NonEmpty b)-unzip = (unsafeToNonEmpty *** unsafeToNonEmpty) . L.unzip . fromNonEmpty+unzip = (unsafeToNonEmpty *** unsafeToNonEmpty) . L.unzip . toList  ----------- -- TESTS --@@ -187,7 +181,7 @@  instance (Arbitrary a) => Arbitrary (NonEmpty a) where   arbitrary = nonEmpty <$> arbitrary <*> arbitrary-  shrink = (unsafeToNonEmpty <$>) . shrink . fromNonEmpty+  shrink = (unsafeToNonEmpty <$>) . shrink . toList  prop_neHead :: String -> [String] -> Bool prop_neHead h t = neHead (nonEmpty h t) == h@@ -209,10 +203,10 @@ prop_unsafeNonEmpty x = not (null x) ==> prop_toNonEmpty x  prop_cons :: String -> NonEmpty String -> Bool-prop_cons a as = fromNonEmpty (a .: as) == a : fromNonEmpty as+prop_cons a as = toList (a .: as) == a : toList as  prop_append :: NonEmpty String -> NonEmpty String -> Bool-prop_append a b = fromNonEmpty (a .++ b) == neHead a : neTail a ++ neHead b : neTail b+prop_append a b = toList (a .++ b) == neHead a : neTail a ++ neHead b : neTail b  prop_reverse :: NonEmpty String -> Bool prop_reverse x = (reverse . reverse) x == x
NonEmptyList.cabal view
@@ -1,5 +1,5 @@ Name:                NonEmptyList-Version:             0.0.4+Version:             0.0.5 License:             BSD3 License-File:        LICENSE Synopsis:            A list with a length of at least one.