microlens-mtl 0.1.6.1 → 0.1.7.0
raw patch · 3 files changed
+21/−5 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Lens.Micro.Mtl: preuse :: MonadState s m => Getting (First a) s a -> m (Maybe a)
Files
- CHANGELOG.md +4/−0
- microlens-mtl.cabal +1/−1
- src/Lens/Micro/Mtl.hs +16/−4
CHANGELOG.md view
@@ -1,3 +1,7 @@+# 0.1.7.0++* Added `preuse`.+ # 0.1.6.1 * Bumped transformers version.
microlens-mtl.cabal view
@@ -1,5 +1,5 @@ name: microlens-mtl-version: 0.1.6.1+version: 0.1.7.0 synopsis: microlens support for Reader/Writer/State from mtl description: This package contains functions (like 'view' or '+=') which work on 'MonadReader', 'MonadWriter', and 'MonadState' from the mtl package.
src/Lens/Micro/Mtl.hs view
@@ -13,9 +13,8 @@ module Lens.Micro.Mtl (- view,- preview,- use,+ view, preview,+ use, preuse, zoom, magnify, (.=), (%=),@@ -67,7 +66,7 @@ {-# INLINE preview #-} {- |-'use' is 'view' which implicitly operates on the state; for instance, if your state is a record containing a field @foo@, you can write+'use' is ('^.) (or 'view') which implicitly operates on the state; for instance, if your state is a record containing a field @foo@, you can write @ x \<- 'use' foo@@ -80,10 +79,23 @@ @ 'use' l = 'State.gets' ('view' l) @++If you need to extract something with a fold or traversal, you need 'preuse'. -} use :: MonadState s m => Getting a s a -> m a use l = State.gets (view l) {-# INLINE use #-}++{- |+'preuse' is ('^?') (or 'preview') which implicitly operates on the state – it takes the state and applies a traversal (or fold) to it to extract the 1st element the traversal points at.++@+'preuse' l = 'State.gets' ('preview' l)+@+-}+preuse :: MonadState s m => Getting (First a) s a -> m (Maybe a)+preuse l = State.gets (preview l)+{-# INLINE preuse #-} infix 4 .=, %=