packages feed

these-optics (empty) → 1

raw patch · 4 files changed

+149/−0 lines, 4 filesdep +basedep +optics-coredep +these

Dependencies added: base, optics-core, these

Files

+ 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/Optics.hs view
@@ -0,0 +1,78 @@+{-# LANGUAGE Trustworthy #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+module Data.These.Optics (+    -- * Affine traversals+    here, there,++    -- * Prisms+    _This, _That, _These,+    ) where++import Data.These+import Data.These.Combinators (swapThese)+import Optics.Core+       (AffineTraversal, Prism', Swapped (..), atraversalVL, iso, prism)++-- $setup+-- >>> import Optics.Core++-------------------------------------------------------------------------------+-- Traversals+-------------------------------------------------------------------------------++-- | An 'AffineTraversal' of the first half of a 'These'.+--+-- >>> over here show (That 1)+-- That 1+--+-- >>> over here show (These 'a' 2)+-- These "'a'" 2+--+here :: AffineTraversal (These a c) (These b c) a b+here = atraversalVL here' where+    here' _     f (This x)    = This <$> f x+    here' _     f (These x y) = flip These y <$> f x+    here' point _ (That x)    = point (That x)++-- | An 'AffineTraversal' of the second half of a 'These'.+--+-- >>> over there show (That 1)+-- That "1"+--+-- >>> over there show (These 'a' 2)+-- These 'a' "2"+--+there :: AffineTraversal (These c a) (These c b) a b+there = atraversalVL there' where+    there' point _ (This x)    = point (This x)+    there' _     f (These x y) = These x <$> f y+    there' _     f (That x)    = That <$> f x++-------------------------------------------------------------------------------+-- Prisms+-------------------------------------------------------------------------------++-- | A '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 '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 '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-optics.cabal view
@@ -0,0 +1,38 @@+cabal-version:      >=1.10+name:               these-optics+version:            1+synopsis:           Optics 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, Optics+build-type:         Simple+extra-source-files: CHANGELOG.md+description:        This package provides Prism and Traversals for @These@.+tested-with:        GHC ==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.Optics++  -- ghc boot libs+  build-depends:    base >=4.9 && <4.13++  -- these+  build-depends:    these >=1 && <1.1++  -- other dependencies+  build-depends:+    optics-core      >=0.1    && <0.2