zippo 0.2 → 0.3
raw patch · 2 files changed
+46/−20 lines, 2 filesdep ~yall
Dependency ranges changed: yall
Files
- Data/Lens/Zipper.hs +41/−15
- zippo.cabal +5/−5
Data/Lens/Zipper.hs view
@@ -41,26 +41,51 @@ ) where -{- TODO-- - either switch to new lens lib, or add TH to your own-- - excellent rewrite rules-- - first look at core output of simple example-- - add rules one-by-one, looking at core-- - change moveP -> pmove?-- - consider a newtype-wrapped submodule encapsulating monad return value-- what we really want is a notation like:-- move x-- move y-- foc <- move z-- moveUp -- modf (+foc)-- quasiquotation, or can we shoe-horn this into proc notation? -- otherwise add those combinators (in notes)+{- TODO (PROBABLY NEVER)+- - test rewrite rules+- - combinators providing pleasant DSL for sequencing zipper ops. - - more advanced motions a.la. pez? - - better demos - - pretty Show instance for Zipper -} +{- REWRITE RULE POSSIBILITIES+ -+ - These may or may not be beneficial, and probably have to be defined+ - in terms of custom combinators (see TODOs) to fire reliably.+ -+ 1) moveUp $ moveUp $ modf/setf $ move y $ move x + => moveUp $ modf/setf $ move (y . x)+ i.e.+ {-# RULE "down-down-modf-up-up/down-modf-up" forall f x y z.moveUp $ moveUp $ modf f $ moveP y $ moveP x z = moveUp $ modf f $ moveP (y . x) z; #-}+ + 1b) close $ modf/setf $ move y $ move x+ => close $ modf/setf $ move (y . x)+ + -- Possible?+ 1c?) move x >>> move y >>> modf/setf .^> (\a -> moveUp >>> moveUp >>> m)+ => move (y . x) >>> modf/setf .^> (\a-> moveUp >>> m)+ + -- 2. convert to lens operations on focus+ -- These probably don't amount to optimizations.+ 2) moveUp $ setf/modf $ move x+ => set/modify (x . focus)+ + 2b) close $ setf/modf $ move x+ => close $ set/modify (x . focus)+ + -- Possible?+ 2c) ...something akin to 1c+ + 3) close $ moveUp+ => close+ + -- 4. somehow, a bunch of lens set and modify ops (w/out and motions) + -- sandwhiched between 'zipper' and 'close' could be extracted from zipper altogether+ 4?) zipper >>> modify (x . focus) >>> set (y . focus) >>> close+ => modify x >>> set y+-}+ import Data.Yall.Lens import Control.Monad.Identity @@ -129,3 +154,4 @@ -- > moveUp (Zipper (Snoc st cont) c) = Zipper st $ cont c moveUp :: Zipper (st :> b) c -> Zipper st b moveUp (Zipper (Snoc st cont) c) = Zipper st $ cont c+
zippo.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version: 0.2+Version: 0.3 -- A short (one-line) description of the package. Synopsis: A simple lens-based, generic, heterogenous, type-checked zipper library@@ -22,11 +22,11 @@ For a similar approach with many more features, but less type-safety see "pez". .- /CHANGES/: 0.1 to 0.2:+ /UPDATE/: I have stopped developing this package; instead look into "lens" v3.0 which includes similar functionality .- - Export all data type implementations (mea culpa!)+ /CHANGES/: 0.2 to 0.3: .- - better documentation+ - depend on new yall, depending on new categories -- URL for the project homepage or repository. Homepage: http://brandon.si/code/zippo/@@ -68,5 +68,5 @@ Exposed-modules: Data.Lens.Zipper Build-depends: mtl >= 2- , yall + , yall >= 0.2.1 , base < 5 && >= 4