lens 2.7 → 2.7.0.1
raw patch · 2 files changed
+51/−1 lines, 2 filesdep ~base
Dependency ranges changed: base
Files
- lens.cabal +2/−1
- src/Control/Lens/Combinators.hs +49/−0
lens.cabal view
@@ -1,6 +1,6 @@ name: lens category: Data, Lenses-version: 2.7+version: 2.7.0.1 license: BSD3 cabal-version: >= 1.8 license-file: LICENSE@@ -150,6 +150,7 @@ Control.Exception.Lens Control.Lens Control.Lens.Action+ Control.Lens.Combinators Control.Lens.Fold Control.Lens.Getter Control.Lens.Indexed
+ src/Control/Lens/Combinators.hs view
@@ -0,0 +1,49 @@+-------------------------------------------------------------------------------+-- |+-- Module : Control.Lens.Combinators+-- Copyright : (C) 2012 Edward Kmett+-- License : BSD-style (see the file LICENSE)+-- Maintainer : Edward Kmett <ekmett@gmail.com>+-- Stability : provisional+-- Portability : portable+--+-------------------------------------------------------------------------------+module Control.Lens.Combinators+ ( (|>)+ , (<$!>), (<$!)+ ) where++infixr 4 <$!>, <$!+infixl 1 |>++-- | Passes the result of the left side to the function on the right side (forward pipe operator).+--+-- This is the flipped version of ('$'), which is more common in languages like F# where it is needed+-- for inference. Here it is supplied for notational convenience and given a precedence that allows it+-- to be nested inside uses of ('$').+--+-- >>> "hello" |> length |> succ+-- 6+(|>) :: a -> (a -> b) -> b+a |> f = f a+{-# INLINE (|>) #-}++-- | A strict version of ('Data.Functor.<$>') for monads.+--+-- >>> (+1) <$!> [1,2,3,4]+-- [2,3,4,5]+(<$!>) :: Monad m => (a -> b) -> m a -> m b+f <$!> m = do+ a <- m+ return $! f a+{-# INLINE (<$!>) #-}++-- | A strict version of ('Data.Functor.<$') for monads.+--+-- >>> () <$! [1,2,3,4]+-- [(),(),(),()]+(<$!) :: Monad m => b -> m a -> m b+b <$! m = do+ _ <- m+ return $! b+{-# INLINE (<$!) #-}