packages feed

zipper-extra 0.1.1.0 → 0.1.2.0

raw patch · 3 files changed

+17/−3 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Control.Comonad.Zipper.Extra: instance GHC.Classes.Eq Control.Comonad.Zipper.Extra.ZipperException
+ Control.Comonad.Zipper.Extra: instance GHC.Exception.Type.Exception Control.Comonad.Zipper.Extra.ZipperException
+ Control.Comonad.Zipper.Extra: instance GHC.Show.Show Control.Comonad.Zipper.Extra.ZipperException
+ Control.Comonad.Zipper.Extra: zipper' :: (MonadThrow m, Traversable t) => t a -> m (Zipper t a)

Files

ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for zipper-extra +## v0.1.2.0++Add `zipper'`, `MonadThrow` version of regular `zipper`.+ ## v0.1.1.0  Add paginate' and exception handling for pagination failure.
src/Control/Comonad/Zipper/Extra.hs view
@@ -10,6 +10,7 @@ , zipperNextMaybe , zipperPreviousMaybe , zipperWithin+, zipper' ) where  import Control.Monad.Catch@@ -47,6 +48,15 @@ zipperPreviousMaybe :: Zipper t a -> Maybe a zipperPreviousMaybe xs = if pos xs > 0 then Just (peeks (+ (-1)) xs) else Nothing --- Return a list of elements within 'r' hops either side of the zipper target.+-- | Return a list of elements within 'r' hops either side of the zipper target. zipperWithin :: Int -> Zipper t a -> [a] zipperWithin r xs = (`peek` xs) <$>  [(max 0 (pos xs - r)) .. (min (size xs -1) (pos xs + r))]++data ZipperException = EmptyZipper+  deriving (Show, Eq, Typeable)++instance Exception ZipperException where+  displayException EmptyZipper = "Can not create an empty zipper."++-- | Like `zipper` but lifted to `MonadThrow`.+zipper' xs = maybe (throwM EmptyZipper) return $ zipper xs
zipper-extra.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: e264b1d11839e03ca02e542e1a114ee5af7a47a5bca3ad75cacf1cfd5bfc49e4+-- hash: a2dff3a722a11cc68cda3cfaf56d455945de1a9c34ee268ad02e049c6a34886a  name:           zipper-extra-version:        0.1.1.0+version:        0.1.2.0 synopsis:       Zipper utils that weren't in Control.Comonad.Store.Zipper description:    Adds some utility functions for and reexports Control.Comonad.Store.Zipper category:       Comonads