microlens 0.4.8.3 → 0.4.9
raw patch · 3 files changed
+26/−2 lines, 3 files
Files
- CHANGELOG.md +5/−0
- microlens.cabal +1/−1
- src/Lens/Micro.hs +20/−1
CHANGELOG.md view
@@ -1,3 +1,8 @@+# 0.4.9++* Added `<>~`.+* Added fixities for `<%~`, `<<%~`, `<<.~`.+ # 0.4.8.3 * Fixed compilation on GHC 8.4.
microlens.cabal view
@@ -1,5 +1,5 @@ name: microlens-version: 0.4.8.3+version: 0.4.9 synopsis: A tiny lens library with no dependencies. If you're writing an app, you probably want microlens-platform, not this. description: NOTE: If you're writing an app, you probably want <http://hackage.haskell.org/package/microlens-platform microlens-platform> – it has the most features. <http://hackage.haskell.org/package/microlens microlens> is intended more for library writers who want a tiny lens library (after all, lenses are pretty useful for everything, not just for updating records!).
src/Lens/Micro.hs view
@@ -38,6 +38,7 @@ ASetter, ASetter', sets, (%~), over,+ (<>~), (.~), set, (?~), (<%~), (<<%~), (<<.~),@@ -291,6 +292,18 @@ {-# INLINE over #-} {- |+('<>~') appends a value monoidally to the target.++>>> ("hello", "goodbye") & both <>~ " world!"+("hello world!", "goodbye world!")+-}+(<>~) :: (Monoid a) => ASetter s t a a -> a -> s -> t+(<>~) l a = over l (`mappend` a)+{-# INLINE (<>~) #-}++infixr 4 <>~++{- | ('.~') assigns a value to the target. It's the same thing as using ('%~') with 'const': @@@ -386,6 +399,8 @@ (<%~) l f = l (join (,) . f) {-# INLINE (<%~) #-} +infixr 4 <%~+ {- | This is a version of ('%~') which modifies the structure and returns it along with the old value: @@ -403,6 +418,8 @@ (<<%~) l f = l (\a -> (a, f a)) {-# INLINE (<<%~) #-} +infixr 4 <<%~+ {- | This is a version of ('.~') which modifies the structure and returns it along with the old value: @@ -420,6 +437,8 @@ (<<.~) l x = l (\a -> (a, x)) {-# INLINE (<<.~) #-} +infixr 4 <<.~+ -- Getting ----------------------------------------------------------------- {- $getters-note@@ -999,7 +1018,7 @@ @ filtered :: (a -> Bool) -> 'Traversal'' a a-filtered p s = if p s then f s else 'pure' s+filtered p f s = if p s then f s else 'pure' s @ By the way, note that 'filtered' can generate illegal traversals – sometimes this can bite you. In particular, an optimisation that should be safe becomes unsafe. (To the best of my knowledge, this optimisation never happens automatically. If you just use 'filtered' to modify/view something, you're safe. If you don't define any traversals that use 'filtered', you're safe too.)