these-lens (empty) → 1
raw patch · 4 files changed
+153/−0 lines, 4 filesdep +basedep +base-compatdep +lens
Dependencies added: base, base-compat, lens, these
Files
- CHANGELOG.md +3/−0
- LICENSE +30/−0
- src/Data/These/Lens.hs +82/−0
- these-lens.cabal +38/−0
+ CHANGELOG.md view
@@ -0,0 +1,3 @@+# 1++Split out of `these` package.
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c)2012, C. McCann++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * 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.++ * Neither the name of C. McCann nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"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 COPYRIGHT+OWNER 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.
+ src/Data/These/Lens.hs view
@@ -0,0 +1,82 @@+{-# LANGUAGE Trustworthy #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+module Data.These.Lens (+ -- * Traversals+ here, there,++ -- * Prisms+ _This, _That, _These,+ ) where++import Prelude ()+import Prelude.Compat++import Control.Lens (Prism', Traversal, Swapped (..), iso, prism)+import Data.These+import Data.These.Combinators (swapThese)++-- $setup+-- >>> import Control.Lens++-------------------------------------------------------------------------------+-- Traversals+-------------------------------------------------------------------------------++-- | A 'Control.Lens.Traversal' of the first half of a 'These', suitable for use with "Control.Lens".+--+-- >>> over here show (That 1)+-- That 1+--+-- >>> over here show (These 'a' 2)+-- These "'a'" 2+--+here :: Traversal (These a c) (These b c) a b+here f (This x) = This <$> f x+here f (These x y) = flip These y <$> f x+here _ (That x) = pure (That x)++-- | A 'Control.Lens.Traversal' of the second half of a 'These', suitable for use with "Control.Lens".+--+-- @+-- 'there' :: 'Control.Lens.Traversal' ('These' t b) ('These' t b) a b+-- @+--+-- >>> over there show (That 1)+-- That "1"+--+-- >>> over there show (These 'a' 2)+-- These 'a' "2"+--+there :: Traversal (These c a) (These c b) a b+there _ (This x) = pure (This x)+there f (These x y) = These x <$> f y+there f (That x) = That <$> f x++-------------------------------------------------------------------------------+-- Prisms+-------------------------------------------------------------------------------++-- | A 'Control.Lens.Prism'' selecting the 'This' constructor.+--+-- /Note:/ cannot change type.+_This :: Prism' (These a b) a+_This = prism This (these Right (Left . That) (\x y -> Left $ These x y))++-- | A 'Control.Lens.Prism'' selecting the 'That' constructor.+--+-- /Note:/ cannot change type.+_That :: Prism' (These a b) b+_That = prism That (these (Left . This) Right (\x y -> Left $ These x y))++-- | A 'Control.Lens.Prism'' selecting the 'These' constructor. 'These' names are ridiculous!+--+-- /Note:/ cannot change type.+_These :: Prism' (These a b) (a, b)+_These = prism (uncurry These) (these (Left . This) (Left . That) (\x y -> Right (x, y)))++-------------------------------------------------------------------------------+-- Orphans+-------------------------------------------------------------------------------++instance Swapped These where+ swapped = iso swapThese swapThese
+ these-lens.cabal view
@@ -0,0 +1,38 @@+cabal-version: >=1.10+name: these-lens+version: 1+synopsis: Lenses for These+homepage: https://github.com/isomorphism/these+license: BSD3+license-file: LICENSE+author: C. McCann, Oleg Grenrus+maintainer: Oleg Grenrus <oleg.grenrus@iki.fi>+category: Data, These, Lens+build-type: Simple+extra-source-files: CHANGELOG.md+description: This package provides Prism and Traversals for @These@.+tested-with:+ GHC ==7.4.2 || ==7.6.3 || ==7.8.4 || ==7.10.3 || ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5 || ==8.8.1++source-repository head+ type: git+ location: https://github.com/isomorphism/these.git++library+ default-language: Haskell2010+ ghc-options: -Wall++ if impl(ghc >=8.0)+ ghc-options: -Wno-trustworthy-safe++ hs-source-dirs: src+ exposed-modules: Data.These.Lens++ -- ghc boot libs+ build-depends: base >=4.5.1.0 && <4.13+ build-depends: these >=1 && <1.1++ -- other dependencies+ build-depends:+ base-compat >=0.10.5 && <0.11+ , lens >=4.17.1 && <4.18