packages feed

smash-microlens (empty) → 0.1.0.0

raw patch · 9 files changed

+383/−0 lines, 9 filesdep +basedep +microlensdep +smashsetup-changed

Dependencies added: base, microlens, smash

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Revision history for smash-microlens++## 0.1.0.0 -- YYYY-mm-dd++* First version. Released on an unsuspecting world.
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2020, Emily Pillmore++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 Emily Pillmore 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.
+ README.md view
@@ -0,0 +1,7 @@+# smash-microlens: Optics for the smash library+++[![Build Status](https://travis-ci.com/emilypi/smash.svg?branch=master)](https://travis-ci.com/emilypi/smash)+[![Hackage](https://img.shields.io/hackage/v/smash-microlens.svg)](https://hackage.haskell.org/package/smash-microlens)++This library provides optics for the [smash](https://hackage.haskell.org/package/smash).
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ smash-microlens.cabal view
@@ -0,0 +1,53 @@+cabal-version:       2.0+++name:                smash-microlens+version:             0.1.0.0+synopsis:            Optics for the `smash` library+description:+  Optics for the `smash` library using `microlens`+homepage:            https://github.com/emilypi/smash+bug-reports:         https://github.com/emilypi/smash/issues+license:             BSD3+license-file:        LICENSE+author:              Emily Pillmore+maintainer:          emilypi@cohomolo.gy+copyright:           (c) 2020 Emily Pillmore <emilypi@cohomolo.gy>+category:            Data+build-type:          Simple+extra-source-files:+  CHANGELOG.md+  README.md+++tested-with:+  GHC ==8.2.2 || ==8.4.3 || ==8.4.4 || ==8.6.3 || ==8.6.5 || ==8.8.3 || ==8.10.1+++source-repository head+  type:     git+  location: https://github.com/emilypi/smash.git+++library+  exposed-modules:     Data.Can.Microlens+                     , Data.Smash.Microlens+                     , Data.Wedge.Microlens+  -- other-modules:+  -- other-extensions:+  build-depends:       base       >=4.10 && <5.0+                     , microlens  >=0.3  && <0.4.12+                     , smash     ^>=0.1++  hs-source-dirs:      src+  default-language:    Haskell2010++  ghc-options:         -Wall+++test-suite smash-microlens-test+  default-language:    Haskell2010+  type:                exitcode-stdio-1.0+  hs-source-dirs:      test+  main-is:             MyLibTest.hs+  build-depends:       base >=4.10 && <5.0
+ src/Data/Can/Microlens.hs view
@@ -0,0 +1,118 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE UndecidableInstances #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+-- |+-- Module       : Data.Can.Microlens+-- Copyright 	: (c) 2020 Emily Pillmore+-- License	: BSD-style+--+-- Maintainer	: Emily Pillmore <emilypi@cohomolo.gy>+-- Stability	: Experimental+-- Portability	: FlexibleInstances, MPTC, Type Families, UndecideableInstances+--+-- 'Prism's and 'Traversal's for the 'Can' datatype.+--+module Data.Can.Microlens+( -- * Traversals+  _Non+, _One+, _Eno+, _Two+, oneing+, enoing+, twoed+, twoing+) where+++import Lens.Micro++import Data.Can+++-- | A 'Traversal' of the first parameter, suitable for use+-- with "Control.Lens".+--+oneing :: Traversal (Can a c) (Can b c) a b+oneing f = \case+  Non -> pure Non+  One a -> One <$> f a+  Eno c -> pure (Eno c)+  Two a c -> flip Two c <$> f a++-- | A 'Traversal' of the second parameter, suitable for use+-- with "Control.Lens".+--+enoing :: Traversal (Can a b) (Can a c) b c+enoing f = \case+  Non -> pure Non+  One a -> pure (One a)+  Eno b -> Eno <$> f b+  Two a b -> Two a <$> f b++-- | A 'Traversal' of the pair, suitable for use+-- with "Control.Lens".+--+twoed :: Traversal' (Can a b) (a,b)+twoed f = \case+  Non -> pure Non+  One a -> pure (One a)+  Eno b -> pure (Eno b)+  Two a b -> uncurry Two <$> f (a,b)++-- | A 'Traversal' of the pair ala 'both', suitable for use+-- with "Control.Lens".+--+twoing :: Traversal (Can a a) (Can b b) a b+twoing f = \case+  Non -> pure Non+  One a -> One <$> f a+  Eno a -> Eno <$> f a+  Two a b -> Two <$> f a <*> f b++-- | A 'Traversal'' selecting the 'Non' constructor.+--+-- /Note:/ cannot change type.+--+_Non :: Traversal' (Can a b) ()+_Non f = \case+  Non -> Non <$ f ()+  One a -> pure (One a)+  Eno b -> pure (Eno b)+  Two a b -> pure (Two a b)++-- | A 'Traversal'' selecting the 'One' constructor.+--+-- /Note:/ cannot change type.+--+_One :: Traversal' (Can a b) a+_One f = \case+  Non -> pure Non+  One a -> One <$> f a+  Eno b -> pure (Eno b)+  Two a b -> pure (Two a b)++-- | A 'Traversal'' selecting the 'Eno' constructor.+--+-- /Note:/ cannot change type.+--+_Eno :: Traversal' (Can a b) b+_Eno f = \case+  Non -> pure Non+  One a -> pure (One a)+  Eno b -> Eno <$> f b+  Two a b -> pure (Two a b)++-- | A 'Traversal'' selecting the 'Two' constructor.+--+-- /Note:/ cannot change type.+--+_Two :: Traversal' (Can a b) (a,b)+_Two f = \case+  Non -> pure Non+  One a -> pure (One a)+  Eno b -> pure (Eno b)+  Two a b -> uncurry Two <$> f (a,b)
+ src/Data/Smash/Microlens.hs view
@@ -0,0 +1,74 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE UndecidableInstances #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+-- |+-- Module       : Data.Smash.Microlens+-- Copyright 	: (c) 2020 Emily Pillmore+-- License	: BSD-style+--+-- Maintainer	: Emily Pillmore <emilypi@cohomolo.gy>+-- Stability	: Experimental+-- Portability	: FlexibleInstances, MPTC, Type Families, UndecideableInstances+--+-- 'Traversal's for the 'Smash' datatype.+--+module Data.Smash.Microlens+( -- * Traversals+  _Nada+, _Smash+, smashed+, smashing+) where+++import Lens.Micro++import Data.Smash+++-- | A 'Traversal' of the smashed pair, suitable for use+-- with "Control.Lens".+--+-- >>> over smashed show (Smash 1 2)+-- "(1,2)"+--+-- >>> over smashed show Nada+-- Nada+--+smashed :: Traversal (Smash a b) (Smash c d) (a,b) (c,d)+smashed f = \case+  Nada -> pure Nada+  Smash a b -> uncurry Smash <$> f (a,b)++-- | A 'Traversal' of the smashed pair, suitable for use+-- with "Control.Lens".+--+-- >>> over smashing show (Smash 1 2)+-- Smash "1" "2"+--+-- >>> over smashing show Nada+-- Nada+--+smashing :: Traversal (Smash a a) (Smash b b) a b+smashing = smashed . both++-- | A 'Traversal'' selecting the 'Nada' constructor.+--+-- /Note:/ cannot change type.+--+_Nada :: Traversal' (Smash a b) ()+_Nada f = \case+  Nada -> Nada <$ f ()+  Smash a b -> pure (Smash a b)++-- | A 'Traversal'' selecting the 'Smash' constructor.+--+-- /Note:/ cannot change type.+--+_Smash :: Traversal' (Smash a b) (a,b)+_Smash f = \case+  Smash a b -> uncurry Smash <$> f (a,b)+  Nada -> pure Nada
+ src/Data/Wedge/Microlens.hs view
@@ -0,0 +1,90 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE UndecidableInstances #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+-- |+-- Module       : Data.Wedge.Microlens+-- Copyright 	: (c) 2020 Emily Pillmore+-- License	: BSD-style+--+-- Maintainer	: Emily Pillmore <emilypi@cohomolo.gy>+-- Stability	: Experimental+-- Portability	: FlexibleInstances, MPTC, Type Families, UndecideableInstances+--+-- 'Prism's and 'Traversal's for the 'Wedge' datatype.+--+module Data.Wedge.Microlens+( -- * Traversals+  here+, there+, _Nowhere+, _Here+, _There+) where+++import Lens.Micro++import Data.Wedge++-- | A 'Control.Lens.Traversal' of the 'Here' case of a 'Wedge',+-- suitable for use with "Control.Lens".+--+-- >>> over here show (Here 1)+-- Here "1"+--+-- >>> over here show (There 'a')+-- There 'a'+--+here :: Traversal' (Wedge a b) a+here f = \case+  Nowhere -> pure Nowhere+  Here a -> Here <$> f a+  There b -> pure (There b)++-- | A 'Control.Lens.Traversal' of the 'There' case of a 'Wedge',+-- suitable for use with "Control.Lens".+--+-- >>> over there show (Here 1)+-- Here 1+--+-- >>> over there show (There 'a')+-- There "'a'"+--+there :: Traversal' (Wedge a b) b+there f = \case+  Nowhere -> pure Nowhere+  Here a -> pure (Here a)+  There b -> There <$> f b++-- | A 'Traversal'' selecting the 'Nowhere' constructor.+--+-- /Note:/ cannot change type.+--+_Nowhere :: Traversal' (Wedge a b) ()+_Nowhere f = \case+  Nowhere -> Nowhere <$ f ()+  Here a -> pure (Here a)+  There b -> pure (There b)++-- | A 'Traversal'' selecting the 'Here' constructor.+--+-- /Note:/ cannot change type.+--+_Here :: Traversal (Wedge a b) (Wedge c b) a c+_Here f = \case+  Here a -> Here <$> f a+  There b -> pure (There b)+  Nowhere -> pure Nowhere++-- | A 'Traversal'' selecting the 'There' constructor.+--+-- /Note:/ cannot change type.+--+_There :: Traversal (Wedge a b) (Wedge a d) b d+_There f = \case+  There b -> There <$> f b+  Here a -> pure (Here a)+  Nowhere -> pure Nowhere
+ test/MyLibTest.hs view
@@ -0,0 +1,4 @@+module Main (main) where++main :: IO ()+main = putStrLn "Test suite not yet implemented."