packages feed

ral-lens 0.1 → 0.2

raw patch · 8 files changed

+104/−13 lines, 8 filesdep ~basedep ~findep ~lens

Dependency ranges changed: base, fin, lens, ral

Files

ChangeLog.md view
@@ -1,5 +1,10 @@ # Version history for ral +## 0.2++- Support `fin-0.2`+- Support `lens-5`+ ## 0.1  - First version. Released on an unsuspecting world.
ral-lens.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.2 name:               ral-lens-version:            0.1+version:            0.2 synopsis:           Length-indexed random access lists: lens utilities. category:           Data, Dependent Types, Singletons, Lens description:@@ -13,7 +13,7 @@ license-file:       LICENSE author:             Oleg Grenrus <oleg.grenrus@iki.fi> maintainer:         Oleg.Grenrus <oleg.grenrus@iki.fi>-copyright:          (c) 2019 Oleg Grenrus+copyright:          (c) 2019-2021 Oleg Grenrus build-type:         Simple extra-source-files: ChangeLog.md tested-with:@@ -23,7 +23,9 @@    || ==8.2.2    || ==8.4.4    || ==8.6.5-   || ==8.8.1+   || ==8.8.4+   || ==8.10.4+   || ==9.0.1  source-repository head   type:     git@@ -39,14 +41,15 @@     Data.RAList.NonEmpty.Lens     Data.RAVec.Lens     Data.RAVec.NonEmpty.Lens+    Data.RAVec.Tree.DF.Lens     Data.RAVec.Tree.Lens    build-depends:-    , base  >=4.7   && <4.14+    , base  >=4.7   && <4.16     , bin   ^>=0.1-    , fin   ^>=0.1.1-    , lens  >=4.16  && <4.19-    , ral   ^>=0.1+    , fin   ^>=0.2+    , lens  >=4.16  && <5.1+    , ral   ^>=0.2  -- dump-core -- if impl(ghc >= 8.0)
src/Data/RAList/Lens.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                   #-} {-# LANGUAGE FlexibleInstances     #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE RankNTypes            #-}@@ -28,6 +29,7 @@ -- Instances ------------------------------------------------------------------------------- +#if !MIN_VERSION_lens(5,0,0) instance L.FunctorWithIndex Int RAList where     imap = imap @@ -36,6 +38,7 @@  instance L.TraversableWithIndex Int RAList where     itraverse = itraverse+#endif  instance L.Each (RAList a) (RAList b) a b @@ -43,4 +46,4 @@ type instance L.IxValue (RAList a) = a  instance L.Ixed (RAList a) where-    ix = ix+    ix i = ix i
src/Data/RAList/NonEmpty/Lens.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                   #-} {-# LANGUAGE FlexibleInstances     #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE RankNTypes            #-}@@ -49,6 +50,7 @@ -- Instances ------------------------------------------------------------------------------- +#if !MIN_VERSION_lens(5,0,0) instance L.FunctorWithIndex Int NERAList where     imap = imap @@ -57,6 +59,7 @@  instance L.TraversableWithIndex Int NERAList where     itraverse = itraverse+#endif  instance L.Each (NERAList a) (NERAList b) a b @@ -64,4 +67,4 @@ type instance L.IxValue (NERAList a) = a  instance L.Ixed (NERAList a) where-    ix = ix+    ix i = ix i
src/Data/RAVec/Lens.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                   #-} {-# LANGUAGE FlexibleInstances     #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE RankNTypes            #-}@@ -20,6 +21,7 @@ -- $setup -- >>> import Control.Lens ((^.), (&), (.~), (^?), (#)) -- >>> import Prelude+-- >>> import Data.RAVec -- >>> import qualified Data.Type.Bin as B  -------------------------------------------------------------------------------@@ -38,6 +40,7 @@ -- Instances ------------------------------------------------------------------------------- +#if !MIN_VERSION_lens(5,0,0) instance L.FunctorWithIndex (Pos b) (RAVec b) where     imap = imap @@ -47,6 +50,7 @@  instance L.TraversableWithIndex (Pos b) (RAVec b) where     itraverse = itraverse+#endif  instance L.Each (RAVec n a) (RAVec n b) a b where     each = traverse@@ -55,4 +59,4 @@ type instance L.IxValue (RAVec n a) = a  instance L.Ixed (RAVec b a) where-    ix = ix+    ix i = ix i
src/Data/RAVec/NonEmpty/Lens.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                   #-} {-# LANGUAGE FlexibleInstances     #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE RankNTypes            #-}@@ -39,6 +40,7 @@ -- Instances ------------------------------------------------------------------------------- +#if !MIN_VERSION_lens(5,0,0) instance L.FunctorWithIndex (PosP b) (NERAVec b) where     imap = imap @@ -58,6 +60,7 @@  instance L.TraversableWithIndex (PosP' n b) (NERAVec' n b) where     itraverse = itraverse'+#endif  instance L.Each (NERAVec n a) (NERAVec n b) a b where     each = traverse@@ -72,7 +75,7 @@ type instance L.IxValue (NERAVec' n b a) = a  instance L.Ixed (NERAVec b a) where-    ix = ix+    ix i = ix i  instance L.Ixed (NERAVec' n b a) where-    ix = ix'+    ix i = ix' i
+ src/Data/RAVec/Tree/DF/Lens.hs view
@@ -0,0 +1,65 @@+{-# LANGUAGE CPP                   #-}+{-# LANGUAGE FlexibleInstances     #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE RankNTypes            #-}+{-# LANGUAGE TypeFamilies          #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+module Data.RAVec.Tree.DF.Lens (+    -- * Indexing+    ix,+    ) where++import Control.Applicative ((<$>))+import Data.Wrd            (Wrd (..))+import Prelude ()++import qualified Control.Lens  as L+import qualified Data.Type.Nat as N++import Data.RAVec.Tree.DF++-- $setup+-- >>> import Control.Lens ((^.), (&), (.~), (^?), (#))+-- >>> import Prelude+-- >>> import Data.RAVec.Tree.DF+-- >>> import Data.Wrd (Wrd (..))++-------------------------------------------------------------------------------+-- Indexing+-------------------------------------------------------------------------------++-- | Index lens.+--+-- >>> let tree = Node (Node (Leaf 'a') (Leaf 'b')) (Node (Leaf 'c') (Leaf 'd'))+-- >>> tree & ix (W1 $ W0 WE) .~ 'z'+-- Node (Node (Leaf 'a') (Leaf 'b')) (Node (Leaf 'z') (Leaf 'd'))+--+ix :: Wrd n -> L.Lens' (Tree n a) a+ix WE      f (Leaf x)   = Leaf <$> f x+ix (W0 is) f (Node x y) = (`Node` y) <$> ix is f x+ix (W1 is) f (Node x y) = (x `Node`) <$> ix is f y++-------------------------------------------------------------------------------+-- Instances+-------------------------------------------------------------------------------++#if !MIN_VERSION_lens(5,0,0)+instance N.SNatI n => L.FunctorWithIndex (Wrd n) (Tree n) where+    imap = imap++instance N.SNatI n => L.FoldableWithIndex (Wrd n) (Tree n) where+    ifoldMap = ifoldMap+    ifoldr   = ifoldr+    ifoldl   = ifoldl++instance N.SNatI n => L.TraversableWithIndex (Wrd n) (Tree n) where+    itraverse = itraverse+#endif++instance N.SNatI n => L.Each (Tree n a) (Tree n b) a b++type instance L.Index (Tree n a)   = Wrd n+type instance L.IxValue (Tree n a) = a++instance L.Ixed (Tree n a) where+    ix i = ix i
src/Data/RAVec/Tree/Lens.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                   #-} {-# LANGUAGE FlexibleInstances     #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE RankNTypes            #-}@@ -18,6 +19,8 @@  -- $setup -- >>> import Control.Lens ((^.), (&), (.~), (^?), (#))+-- >>> import Data.RAVec.Tree+-- >>> import Data.Wrd (Wrd (..)) -- >>> import Prelude  -------------------------------------------------------------------------------@@ -39,6 +42,7 @@ -- Instances ------------------------------------------------------------------------------- +#if !MIN_VERSION_lens(5,0,0) instance L.FunctorWithIndex (Wrd n) (Tree n) where     imap = imap @@ -49,6 +53,7 @@  instance L.TraversableWithIndex (Wrd n) (Tree n) where     itraverse = itraverse+#endif  instance L.Each (Tree n a) (Tree n b) a b @@ -56,4 +61,4 @@ type instance L.IxValue (Tree n a) = a  instance L.Ixed (Tree n a) where-    ix = ix+    ix i = ix i