packages feed

microlens 0.4.2.1 → 0.4.3.0

raw patch · 4 files changed

+32/−4 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Lens.Micro: infixl 1 &
- Lens.Micro: infixl 5 `failing`
- Lens.Micro: infixl 8 ^?!
- Lens.Micro: infixr 4 .~
- Lens.Micro: instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (Lens.Micro.StateT s m)
+ Lens.Micro: (?~) :: ASetter s t a (Maybe b) -> b -> s -> t
- Lens.Micro.Internal: each :: (Each s t a b, Traversable g, s ~ g a, t ~ g b) => Traversal s t a b
+ Lens.Micro.Internal: each :: Each s t a b => Traversal s t a b
- Lens.Micro.Internal: ix :: (Ixed m, At m) => Index m -> Traversal' m (IxValue m)
+ Lens.Micro.Internal: ix :: Ixed m => Index m -> Traversal' m (IxValue m)

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+# 0.4.3.0++* Added `?~`.+ # 0.4.2.1  * Added forgotten copyright/authorship information.@@ -55,6 +59,7 @@  * Moved `Lens.Micro.Classes` into `Lens.Micro.Internal`. * Added `<%~`, `<<%~`, `<<.~`.+* Added `_head`, `_tail`, `_init`, `_last`.  # 0.2.0.0 
microlens.cabal view
@@ -1,5 +1,5 @@ name:                microlens-version:             0.4.2.1+version:             0.4.3.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.
src/Lens/Micro.hs view
@@ -26,6 +26,7 @@   sets,   (%~), over,   (.~), set,+  (?~),   (<%~), (<<%~), (<<.~),   mapped, @@ -279,6 +280,24 @@ set :: ASetter s t a b -> b -> s -> t set l b = runIdentity #. l (\_ -> Identity b) {-# 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').
src/Lens/Micro/Internal.hs view
@@ -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+@ -'at' is often used with 'Lens.Micro.non'.+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'. 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@: