Hello community,

here is the log from the commit of package ghc-microlens for openSUSE:Factory 
checked in at 2016-05-31 12:24:27
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-microlens (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-microlens.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-microlens"

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-microlens/ghc-microlens.changes      
2016-05-11 16:37:24.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.ghc-microlens.new/ghc-microlens.changes 
2016-05-31 12:24:28.000000000 +0200
@@ -1,0 +2,12 @@
+Tue May 24 19:31:03 UTC 2016 - [email protected]
+
+- update to 0.4.4.0
+* Added mapAccumLOf.
+
+-------------------------------------------------------------------
+Thu May  5 06:41:43 UTC 2016 - [email protected]
+
+- update to 0.4.3.0
+* Added ?~.
+
+-------------------------------------------------------------------

Old:
----
  microlens-0.4.2.1.tar.gz

New:
----
  microlens-0.4.4.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-microlens.spec ++++++
--- /var/tmp/diff_new_pack.UDWHbg/_old  2016-05-31 12:24:28.000000000 +0200
+++ /var/tmp/diff_new_pack.UDWHbg/_new  2016-05-31 12:24:28.000000000 +0200
@@ -18,7 +18,7 @@
 %global pkg_name microlens
 
 Name:           ghc-%{pkg_name}
-Version:        0.4.2.1
+Version:        0.4.4.0
 Release:        0
 Summary:        A tiny part of the lens library with no dependencies
 Group:          System/Libraries

++++++ microlens-0.4.2.1.tar.gz -> microlens-0.4.4.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/microlens-0.4.2.1/CHANGELOG.md 
new/microlens-0.4.4.0/CHANGELOG.md
--- old/microlens-0.4.2.1/CHANGELOG.md  2016-04-08 21:37:23.000000000 +0200
+++ new/microlens-0.4.4.0/CHANGELOG.md  2016-05-23 22:15:32.000000000 +0200
@@ -1,3 +1,11 @@
+# 0.4.4.0
+
+* Added `mapAccumLOf`.
+
+# 0.4.3.0
+
+* Added `?~`.
+
 # 0.4.2.1
 
 * Added forgotten copyright/authorship information.
@@ -55,6 +63,7 @@
 
 * Moved `Lens.Micro.Classes` into `Lens.Micro.Internal`.
 * Added `<%~`, `<<%~`, `<<.~`.
+* Added `_head`, `_tail`, `_init`, `_last`.
 
 # 0.2.0.0
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/microlens-0.4.2.1/microlens.cabal 
new/microlens-0.4.4.0/microlens.cabal
--- old/microlens-0.4.2.1/microlens.cabal       2016-04-08 21:37:23.000000000 
+0200
+++ new/microlens-0.4.4.0/microlens.cabal       2016-05-23 22:16:48.000000000 
+0200
@@ -1,5 +1,5 @@
 name:                microlens
-version:             0.4.2.1
+version:             0.4.4.0
 synopsis:            A tiny part of the lens library with no dependencies
 description:
   This is an extract from <http://hackage.haskell.org/package/lens lens> (with 
no dependencies). It's not a toy lenses library, unsuitable for “real world”, 
but merely a small one. It is compatible with lens, and should have same 
performance. It also has better documentation.
@@ -12,7 +12,7 @@
   .
   Don't use this library:
   .
-    * if you need @Iso@s, @Prism@s, indexed traversals, or actually anything 
else which isn't defined here
+    * if you need @Iso@s, @Prism@s, indexed traversals, or actually anything 
else which isn't defined here (tho some indexed functions are available 
elsewhere – containers and vector provide them for their types, and 
<http://hackage.haskell.org/package/ilist ilist> provides indexed functions for 
lists)
   .
     * if you want a library with a clean, understandable implementation (in 
which case you're looking for <http://hackage.haskell.org/package/lens-simple 
lens-simple>)
   .
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/microlens-0.4.2.1/src/Lens/Micro/Internal.hs 
new/microlens-0.4.4.0/src/Lens/Micro/Internal.hs
--- old/microlens-0.4.2.1/src/Lens/Micro/Internal.hs    2016-04-08 
21:37:23.000000000 +0200
+++ new/microlens-0.4.4.0/src/Lens/Micro/Internal.hs    2016-05-23 
21:02:23.000000000 +0200
@@ -280,11 +280,15 @@
 Data.Map.delete k m = m 'Lens.Micro.&' at k 'Lens.Micro..~' Nothing
 @
 
-'at' doesn't work for arrays, because you can't delete an arbitrary element 
from an array.
+Or you could use ('Lens.Micro.?~') instead of ('Lens.Micro..~'):
 
-If you want to modify an already existing value, you should use 'ix' instead 
because then you won't have to deal with 'Maybe' ('ix' is available for all 
types that have 'at').
+@
+Data.Map.insert k a m = m 'Lens.Micro.&' at k 'Lens.Micro.?~' a
+@
+
+Note that 'at' doesn't work for arrays or lists. You can't delete an arbitrary 
element from an array (what would be left in its place?), and you can't set an 
arbitrary element in a list because if the index is out of list's bounds, you'd 
have to somehow fill the stretch between the last element and the element you 
just inserted (i.e. @[1,2,3] & at 10 .~ 5@ is undefined). If you want to modify 
an already existing value in an array or list, you should use 'ix' instead.
 
-'at' is often used with 'Lens.Micro.non'.
+'at' is often used with 'Lens.Micro.non'. See the documentation of 
'Lens.Micro.non' for examples.
 
 Note that 'at' isn't strict for @Map@, even if you're using @Data.Map.Strict@:
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/microlens-0.4.2.1/src/Lens/Micro.hs 
new/microlens-0.4.4.0/src/Lens/Micro.hs
--- old/microlens-0.4.2.1/src/Lens/Micro.hs     2016-04-08 21:37:23.000000000 
+0200
+++ new/microlens-0.4.4.0/src/Lens/Micro.hs     2016-05-23 22:09:08.000000000 
+0200
@@ -26,6 +26,7 @@
   sets,
   (%~), over,
   (.~), set,
+  (?~),
   (<%~), (<<%~), (<<.~),
   mapped,
 
@@ -67,6 +68,7 @@
   each,
   ix,
   _head, _tail, _init, _last,
+  mapAccumLOf,
 
   -- * Prism: a traversal iterating over at most 1 element
   -- $prisms-note
@@ -87,6 +89,7 @@
 import Data.Functor.Identity
 import Data.Monoid
 import Data.Maybe
+import Data.Tuple
 import qualified Data.Foldable as F
 import Unsafe.Coerce
 
@@ -281,6 +284,24 @@
 {-# INLINE set #-}
 
 {- |
+('?~') is a version of ('.~') that wraps the value into 'Just' before setting.
+
+@
+l ?~ b = l .~ Just b
+@
+
+It can be useful in combination with 'at':
+
+>>> Map.empty & at 3 ?~ x
+fromList [(3,x)]
+-}
+(?~) :: ASetter s t a (Maybe b) -> b -> s -> t
+l ?~ b = set l (Just b)
+{-# INLINE (?~) #-}
+
+infixr 4 ?~
+
+{- |
 'mapped' is a setter for everything contained in a functor. You can use it to 
map over lists, @Maybe@, or even @IO@ (which is something you can't do with 
'traversed' or 'each').
 
 Here 'mapped' is used to turn a value to all non-'Nothing' values in a list:
@@ -887,6 +908,20 @@
 _last = _Snoc._2
 {-# INLINE _last #-}
 
+
+{- |
+This generalizes 'Data.Traversable.mapAccumL' to an arbitrary 'Traversal'. 
(Note that it doesn't work on folds, only traversals.)
+
+@
+'mapAccumL' ≡ 'mapAccumLOf' 'traverse'
+@
+-}
+mapAccumLOf :: LensLike (State acc) s t a b -> (acc -> a -> (acc, b)) -> acc 
-> s -> (acc, t)
+mapAccumLOf l f acc0 s = swap (runState (l g s) acc0)
+  where
+    g a = state $ \acc -> swap (f acc a)
+{-# INLINE mapAccumLOf #-}
+
 -- Prisms ------------------------------------------------------------------
 
 {- $prisms-note


Reply via email to