Skip to content
Browse files

more laws, tests and signatures for (#)

  • Loading branch information...
1 parent 445ecb2 commit 846d5d493dac4136e034c7756fc38c3884c15e51 @ekmett committed
Showing with 20 additions and 0 deletions.
  1. +20 −0 src/Control/Lens/Review.hs
View
20 src/Control/Lens/Review.hs
@@ -41,6 +41,7 @@ import Data.Profunctor.Unsafe
-- $setup
-- >>> import Control.Lens
+-- >>> import Numeric.Lens
-- >>> let isLeft (Left _) = True; isLeft _ = False
-- >>> let isRight (Right _) = True; isRight _ = False
@@ -136,8 +137,27 @@ review p = asks (runIdentity #. runReviewed #. p .# Reviewed .# Identity)
-- | An infix alias for 'review'.
--
+-- @
+-- 'unto' f '#' x ≡ f x
+-- l '#' x ≡ x '^.' 're' l
+-- @
+--
+-- This is commonly used when using a 'Prism' as a smart constructor.
+--
-- >>> _Left # 4
-- Left 4
+--
+-- But it can be used for any 'Prism'
+--
+-- >>> base 16 # 123
+-- "7b"
+--
+-- @
+-- ('#') :: 'Iso'' s a -> a -> s
+-- ('#') :: 'Prism'' s a -> a -> s
+-- ('#') :: 'Review'' s a -> a -> s
+-- ('#') :: 'Equality'' s a -> a -> s
+-- @
(#) :: AReview s t a b -> b -> t
(#) p = runIdentity #. runReviewed #. p .# Reviewed .# Identity

0 comments on commit 846d5d4

Please sign in to comment.
Something went wrong with that request. Please try again.