data-lens-fd (empty) → 1.8.0
raw patch · 4 files changed
+163/−0 lines, 4 filesdep +basedep +comonaddep +comonad-transformerssetup-changed
Dependencies added: base, comonad, comonad-transformers, data-lens, mtl, semigroups, transformers
Files
- Data/Lens.hs +93/−0
- LICENSE +30/−0
- Setup.hs +2/−0
- data-lens-fd.cabal +38/−0
+ Data/Lens.hs view
@@ -0,0 +1,93 @@+module Data.Lens+ ( module Data.Lens.Common+ -- * State API+ , access -- getter -- :: MonadState a m => Lens a b -> m b+ , (~=), (!=) -- setter -- :: MonadState a m => Lens a b -> b -> m b+ , (%=), (!%=) -- modify -- :: MonadState a m => Lens a b -> (b -> b) -> m b+ , (%%=), (!%%=) -- modify -- :: MonadState a m => Lens a b -> (b -> (c, b)) -> m c+ , (+=), (!+=) -- modify -- :: (MonadState a m, Num b) => Lens a b -> b -> m b+ , (-=), (!-=) -- modify -- :: (MonadState a m, Num b) => Lens a b -> b -> m b+ , (*=), (!*=) -- modify -- :: (MonadState a m, Num b) => Lens a b -> b -> m b+ , (//=), (!/=) -- modify -- :: (MonadState a m, Fractional b) => Lens a b -> b -> m b+ , (&&=), (!&&=) -- modify -- :: MonadState a m => Lens a Bool -> Bool -> m Bool+ , (||=), (!||=) -- modify -- :: MonadState a m => Lens a Bool -> Bool -> m Bool+ ) where++import Control.Comonad.Trans.Store+import Control.Monad.State+import Data.Functor.Identity+import Data.Lens.Common++-- * State actions++-- | get the value of a lens into state+access :: MonadState a m => Lens a b -> m b+access (Lens f) = gets (pos . f)+{-# INLINE access #-}++infixr 4 ~=, !=++-- | set a value using a lens into state+(~=), (!=) :: MonadState a m => Lens a b -> b -> m b+Lens f ~= b = do+ modify (peek b . f)+ return b+Lens f != b = do+ StoreT (Identity h) _ <- gets f+ put (h $! b)+ return b++infixr 4 %=, !%=+ +-- | infix modification a value through a lens into state+(%=), (!%=) :: MonadState a m => Lens a b -> (b -> b) -> m b+Lens f %= g = do+ StoreT (Identity h) b <- gets f+ let b' = g b+ put (h b')+ return b'+Lens f !%= g = do+ StoreT (Identity h) b <- gets f+ let b' = g b+ b' `seq` put (h b')+ return b'++infixr 4 %%=, !%%=++-- | infix modification of a value through a lens into state+-- with a supplemental response+(%%=), (!%%=) :: MonadState a m => Lens a b -> (b -> (c, b)) -> m c+Lens f %%= g = do+ StoreT (Identity h) b <- gets f+ let (c, b') = g b+ put (h b')+ return c+Lens f !%%= g = do+ StoreT (Identity h) b <- gets f+ let (c, b') = g b+ b' `seq` put (h b')+ return c++infixr 4 +=, !+=, -=, !-=, *=, !*=++(+=), (!+=), (-=), (!-=), (*=), (!*=) :: (MonadState a m, Num b) => Lens a b -> b -> m b+f += b = f %= (+ b)+f -= b = f %= subtract b+f *= b = f %= (* b)+f !+= b = f !%= (+ b)+f !-= b = f !%= subtract b+f !*= b = f !%= (* b)++infixr 4 //=, !/=++(//=), (!/=) :: (MonadState a m, Fractional b) => Lens a b -> b -> m b+f //= b = f %= (/ b)+f !/= b = f !%= (/ b)++infixr 4 &&=, !&&=, ||=, !||=++(&&=), (||=), (!&&=), (!||=) :: MonadState a m => Lens a Bool -> Bool -> m Bool+f &&= b = f %= (&& b)+f ||= b = f %= (|| b)+f !&&= b = f !%= (&& b)+f !||= b = f !%= (|| b)
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright 2008-2011 Edward Kmett++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:++1. Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright+ notice, this list of conditions and the following disclaimer in the+ documentation and/or other materials provided with the distribution.++3. Neither the name of the author nor the names of his contributors+ may be used to endorse or promote products derived from this software+ without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE+POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ data-lens-fd.cabal view
@@ -0,0 +1,38 @@+name: data-lens-fd+category: Control, Comonads+version: 1.8.0+license: BSD3+cabal-version: >= 1.6+license-file: LICENSE+author: Edward A. Kmett+maintainer: Edward A. Kmett <ekmett@gmail.com>+stability: provisional+homepage: git://github.com/ekmett/data-lens-fd/+copyright: Copyright (C) 2011 Edward A. Kmett+synopsis: Lenses+description: Lenses+build-type: Simple++source-repository head+ type: git+ location: git://github.com/ekmett/data-lens-fd.git++flag DeriveDataTypeable+ manual: False+ default: True++library+ build-depends: + base >= 4 && < 4.4,+ transformers >= 0.2 && < 0.3,+ mtl >= 2.0.1.0 && <= 2.1,+ semigroups >= 0.5 && < 0.6,+ comonad >= 1.1 && < 1.2,+ data-lens >= 1.8 && < 1.9,+ comonad-transformers >= 1.8 && < 1.9++ exposed-modules:+ Data.Lens++ ghc-options: -Wall +