packages feed

zipper-extra (empty) → 0.1.0.0

raw patch · 6 files changed

+108/−0 lines, 6 filesdep +basedep +comonaddep +comonad-extrassetup-changed

Dependencies added: base, comonad, comonad-extras, split

Files

+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Changelog for zipper-extra++## v0.1.0.0++Reexport `Control.Comonad.Store.Zipper` with some utility functions.
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Author name here (c) 2020++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Author name here nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,3 @@+# zipper-extra++Zipper utils that weren't in `Control.Comonad.Store.Zipper`.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Control/Comonad/Zipper/Extra.hs view
@@ -0,0 +1,32 @@+module Control.Comonad.Zipper.Extra (+  Control.Comonad.Store.Zipper.Zipper(..)+, Control.Comonad.Store.Zipper.zipper+, Control.Comonad.Store.Zipper.zipper1+, Control.Comonad.Store.Zipper.unzipper+, Control.Comonad.Store.Zipper.size+, paginate+, zipperNextMaybe+, zipperPreviousMaybe+, zipperWithin+) where++import Control.Comonad.Store+import Control.Comonad.Store.Zipper+import Data.List.Split++-- | Turn a list into a zipper of chunks of length n+paginate :: Int -> [a] -> Maybe (Zipper [] [a])+paginate n = zipper . chunksOf n++-- | Return the peek of the next element if it exists.+zipperNextMaybe :: Zipper t a -> Maybe a+zipperNextMaybe xs = if pos xs < size xs-1 then Just (peeks (+1) xs) else Nothing++-- | Return the peek of the previous element if it exists.+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.+zipperWithin :: Int -> Zipper t a -> [a]+zipperWithin r xs = (`peek` xs) <$>  [(max 0 (pos xs - r)) .. (min (size xs -1) (pos xs + r))]+
+ zipper-extra.cabal view
@@ -0,0 +1,36 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.33.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: b0fdea70ba7b0a6ac82f3d0b44aab0a37a27b09a0e43afb72cc42cdf53716b56++name:           zipper-extra+version:        0.1.0.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+author:         Daniel Firth+maintainer:     dan.firth@homotopic.tech+copyright:      2020 Daniel Firth+license:        MIT+license-file:   LICENSE+build-type:     Simple+extra-source-files:+    README.md+    ChangeLog.md++library+  exposed-modules:+      Control.Comonad.Zipper.Extra+  other-modules:+      Paths_zipper_extra+  hs-source-dirs:+      src+  build-depends:+      base >=4.7 && <5+    , comonad+    , comonad-extras+    , split+  default-language: Haskell2010