packages feed

lens 4.3 → 4.3.1

raw patch · 4 files changed

+30/−4 lines, 4 filesdep ~aeson

Dependency ranges changed: aeson

Files

CHANGELOG.markdown view
@@ -1,3 +1,8 @@+4.3.1+---+* Added `Data.Bits.bytewise`+* Support `aeson` 0.8.0.0+ 4.3 --- * Switched the "direction" of the `Iso` argument to `au` to match the order generated by `makePrisms` and `makeLenses`.
lens.cabal view
@@ -1,6 +1,6 @@ name:          lens category:      Data, Lenses, Generics-version:       4.3+version:       4.3.1 license:       BSD3 cabal-version: >= 1.8 license-file:  LICENSE@@ -181,7 +181,7 @@  library   build-depends:-    aeson                     >= 0.7.0.5  && < 0.8,+    aeson                     >= 0.7.0.5  && < 0.9,     attoparsec                >= 0.10     && < 0.13,     array                     >= 0.3.0.2  && < 0.6,     base                      >= 4.3      && < 5,
src/Control/Lens/Iso.hs view
@@ -497,8 +497,8 @@ -- | Lift two 'Iso's into both arguments of a 'Bifunctor'. -- -- @--- bimapping :: 'Profunctor' p => 'Iso' s t a b -> 'Iso' s' t' a' b' -> 'Iso' (p s s') (p t t') (p a a') (p b b')--- bimapping :: 'Profunctor' p => 'Iso'' s a -> 'Iso'' s' a' -> 'Iso'' (p s s') (p a a')+-- bimapping :: 'Bifunctor' p => 'Iso' s t a b -> 'Iso' s' t' a' b' -> 'Iso' (p s s') (p t t') (p a a') (p b b')+-- bimapping :: 'Bifunctor' p => 'Iso'' s a -> 'Iso'' s' a' -> 'Iso'' (p s s') (p a a') -- @ bimapping :: (Bifunctor f, Bifunctor g) => AnIso s t a b -> AnIso s' t' a' b' -> Iso (f s s') (g t t') (f a a') (g b b') bimapping f g = withIso f $ \ sa bt -> withIso g $ \s'a' b't' ->
src/Data/Bits/Lens.hs view
@@ -16,6 +16,7 @@   , bitAt   , bits   , byteAt+  , bytewise   ) where  import Control.Lens@@ -223,3 +224,23 @@   step (n,True) r = setBit r n   step _        r = r {-# INLINE bits #-}++-- | Traverse over all the bytes in an integral type, from the low end.+--+-- The byte position is available as the index.+--+-- >>> toListOf bytewise (1312301580 :: Word32)+-- [12,34,56,78]+--+-- If you supply this an 'Integer', the result will be an infinite 'Traversal',+-- which can be productively consumed, but not reassembled.+--+-- Why is this function called @bytes@ to match 'bits'? Alas, there is already+-- a function by that name in "Data.ByteString.Lens".+bytewise :: (Integral b, Bits b) => IndexedTraversal' Int b Word8+bytewise f b = Prelude.foldr step 0 <$> traverse g bs where+  g n = (,) n <$> indexed f n (fromIntegral $ b `shiftR` (n*8))+  bs = Prelude.takeWhile hasByte [0..]+  hasByte n = complementBit b (n*8) /= b+  step (n,x) r = r .|. (fromIntegral x `shiftL` (n*8))+{-# INLINE bytewise #-}