vec-lens 0.3 → 0.4
raw patch · 6 files changed
+48/−22 lines, 6 filesdep ~basedep ~findep ~lens
Dependency ranges changed: base, fin, lens, vec
Files
- ChangeLog.md +4/−0
- src/Data/Vec/DataFamily/SpineStrict/Lens.hs +16/−10
- src/Data/Vec/Lazy/Inline/Lens.hs +7/−4
- src/Data/Vec/Lazy/Lens.hs +7/−1
- src/Data/Vec/Pull/Lens.hs +5/−0
- vec-lens.cabal +9/−7
ChangeLog.md view
@@ -1,5 +1,9 @@ # Revision history for vec +## 0.4++- Support `fin-0.2`+ ## 0.3 - Split out of `vec`
src/Data/Vec/DataFamily/SpineStrict/Lens.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}@@ -32,6 +33,9 @@ -- >>> :set -XScopedTypeVariables -- >>> import Prelude (Maybe (..), Char, Bool (..)) -- >>> import Control.Lens ((^.), (&), (.~), over, (^?), (#))+-- >>> import qualified Data.Type.Nat as N+-- >>> import Data.Fin (Fin (..))+-- >>> import Data.Vec.DataFamily.SpineStrict ------------------------------------------------------------------------------- -- Indexing@@ -63,7 +67,7 @@ {-# INLINE _tail #-} -- | An 'I.Iso' from 'toPull' and 'fromPull'.-_Pull :: N.InlineInduction n => L.Iso (Vec n a) (Vec n b) (P.Vec n a) (P.Vec n b)+_Pull :: N.SNatI n => L.Iso (Vec n a) (Vec n b) (P.Vec n a) (P.Vec n b) _Pull = L.iso toPull fromPull -- | Prism from list.@@ -77,7 +81,7 @@ -- >>> _Vec # (True ::: False ::: VNil) -- [True,False] ---_Vec :: N.InlineInduction n => L.Prism' [a] (Vec n a)+_Vec :: N.SNatI n => L.Prism' [a] (Vec n a) _Vec = L.prism' toList fromList -- | Index lens.@@ -88,8 +92,8 @@ -- >>> ('a' ::: 'b' ::: 'c' ::: VNil) & ix (FS FZ) .~ 'x' -- 'a' ::: 'x' ::: 'c' ::: VNil ---ix :: forall n f a. (N.InlineInduction n, Functor f) => Fin n -> L.LensLike' f (Vec n a) a-ix = getIxLens $ N.inlineInduction1 start step where+ix :: forall n f a. (N.SNatI n, Functor f) => Fin n -> L.LensLike' f (Vec n a) a+ix f = getIxLens (N.induction1 start step) f where start :: IxLens f 'Z a start = IxLens F.absurd @@ -105,17 +109,19 @@ -- Instances ------------------------------------------------------------------------------- -instance N.InlineInduction n => L.FunctorWithIndex (Fin n) (Vec n) where+#if !MIN_VERSION_lens(5,0,0)+instance N.SNatI n => L.FunctorWithIndex (Fin n) (Vec n) where imap = imap -instance N.InlineInduction n => L.FoldableWithIndex (Fin n) (Vec n) where+instance N.SNatI n => L.FoldableWithIndex (Fin n) (Vec n) where ifoldMap = ifoldMap ifoldr = ifoldr -instance N.InlineInduction n => L.TraversableWithIndex (Fin n) (Vec n) where+instance N.SNatI n => L.TraversableWithIndex (Fin n) (Vec n) where itraverse = itraverse+#endif -instance N.InlineInduction n => L.Each (Vec n a) (Vec n b) a b where+instance N.SNatI n => L.Each (Vec n a) (Vec n b) a b where each = traverse type instance L.Index (Vec n a) = Fin n@@ -123,8 +129,8 @@ -- | 'Vec' doesn't have 'L.At' instance, as we __cannot__ remove value from 'Vec'. -- See 'ix' in "Data.Vec.DataFamily.SpineStrict" module for an 'L.Lens' (not 'L.Traversal').-instance N.InlineInduction n => L.Ixed (Vec n a) where- ix = ix+instance N.SNatI n => L.Ixed (Vec n a) where+ ix i = ix i instance L.Field1 (Vec ('S n) a) (Vec ('S n) a) a a where _1 = _head
src/Data/Vec/Lazy/Inline/Lens.hs view
@@ -27,8 +27,11 @@ -- $setup -- >>> :set -XScopedTypeVariables+-- >>> import Data.Vec.Lazy.Inline+-- >>> import Data.Fin (Fin (..)) -- >>> import Prelude (Maybe (..), Char, Bool (..)) -- >>> import Control.Lens ((^.), (&), (.~), over, (^?), (#))+-- >>> import qualified Data.Type.Nat as N ------------------------------------------------------------------------------- -- Indexing@@ -42,8 +45,8 @@ -- >>> ('a' ::: 'b' ::: 'c' ::: VNil) & ix (FS FZ) .~ 'x' -- 'a' ::: 'x' ::: 'c' ::: VNil ---ix :: forall n f a. (N.InlineInduction n, Functor f) => Fin n -> L.LensLike' f (Vec n a) a-ix = getIxLens $ N.inlineInduction1 start step where+ix :: forall n f a. (N.SNatI n, Functor f) => Fin n -> L.LensLike' f (Vec n a) a+ix = getIxLens $ N.induction1 start step where start :: IxLens f 'Z a start = IxLens F.absurd @@ -59,7 +62,7 @@ ------------------------------------------------------------------------------- -- | An 'L.Iso' from 'toPull' and 'fromPull'.-_Pull :: N.InlineInduction n => L.Iso (Vec n a) (Vec n b) (P.Vec n a) (P.Vec n b)+_Pull :: N.SNatI n => L.Iso (Vec n a) (Vec n b) (P.Vec n a) (P.Vec n b) _Pull = L.iso toPull fromPull -- | Prism from list.@@ -73,5 +76,5 @@ -- >>> _Vec # (True ::: False ::: VNil) -- [True,False] ---_Vec :: N.InlineInduction n => L.Prism' [a] (Vec n a)+_Vec :: N.SNatI n => L.Prism' [a] (Vec n a) _Vec = L.prism' toList fromList
src/Data/Vec/Lazy/Lens.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}@@ -29,8 +30,11 @@ -- $setup -- >>> :set -XScopedTypeVariables+-- >>> import Data.Vec.Lazy+-- >>> import Data.Fin (Fin (..)) -- >>> import Prelude (Maybe (..), Char, Bool (..)) -- >>> import Control.Lens ((^.), (&), (.~), over, (^?), (#))+-- >>> import qualified Data.Type.Nat as N ------------------------------------------------------------------------------- -- Indexing@@ -99,6 +103,7 @@ -- Instances ------------------------------------------------------------------------------- +#if !MIN_VERSION_lens(5,0,0) instance L.FunctorWithIndex (Fin n) (Vec n) where imap = imap @@ -108,6 +113,7 @@ instance L.TraversableWithIndex (Fin n) (Vec n) where itraverse = itraverse+#endif instance L.Each (Vec n a) (Vec n b) a b where each = traverse@@ -118,7 +124,7 @@ -- | 'Vec' doesn't have 'L.At' instance, as we __cannot__ remove value from 'Vec'. -- See 'ix' in "Data.Vec.Lazy" module for an 'L.Lens' (not 'L.Traversal'). instance L.Ixed (Vec n a) where- ix = ix+ ix i = ix i instance L.Field1 (Vec ('S n) a) (Vec ('S n) a) a a where _1 = _head
src/Data/Vec/Pull/Lens.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE MultiParamTypeClasses #-}@@ -24,6 +25,8 @@ -- $setup -- >>> :set -XScopedTypeVariables+-- >>> import Data.Vec.Pull+-- >>> import Data.Fin (Fin (..)) -- >>> import Control.Lens ((^.), (&), (.~), over) -- >>> import qualified Data.Vec.Lazy as L -- >>> import qualified Data.Vec.Lazy.Lens as L@@ -85,9 +88,11 @@ -- Instances ------------------------------------------------------------------------------- +#if !MIN_VERSION_lens(5,0,0) instance L.FunctorWithIndex (Fin n) (Vec n) where imap = imap instance N.SNatI n => L.FoldableWithIndex (Fin n) (Vec n) where ifoldMap = ifoldMap ifoldr = ifoldr+#endif
vec-lens.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: vec-lens-version: 0.3+version: 0.4 synopsis: Vec: length-indexed (sized) list: lens support category: Data, Dependent Types, Lens description:@@ -16,7 +16,7 @@ license-file: LICENSE author: Oleg Grenrus <oleg.grenrus@iki.fi> maintainer: Oleg.Grenrus <oleg.grenrus@iki.fi>-copyright: (c) 2017-2019 Oleg Grenrus+copyright: (c) 2017-2021 Oleg Grenrus build-type: Simple extra-source-files: ChangeLog.md tested-with:@@ -26,7 +26,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@@ -45,15 +47,15 @@ Data.Vec.Pull.Lens -- GHC boot libs- build-depends: base >=4.7 && <4.14+ build-depends: base >=4.7 && <4.16 -- siblings build-depends:- , fin ^>=0.1.1- , vec ^>=0.3+ , fin ^>=0.2+ , vec ^>=0.4 -- other dependencies- build-depends: lens ^>=4.18.1+ build-depends: lens ^>=4.18.1 || ^>=4.19.1 || ^>=5 other-extensions: CPP FlexibleContexts