packages feed

smash-microlens 0.1.0.2 → 0.2.0

raw patch · 9 files changed

+123/−26 lines, 9 filesdep +QuickCheckdep +smash-microlensdep +tastydep ~basedep ~microlensdep ~smashPVP ok

version bump matches the API change (PVP)

Dependencies added: QuickCheck, smash-microlens, tasty, tasty-hunit, tasty-quickcheck

Dependency ranges changed: base, microlens, smash

API changes (from Hackage documentation)

- Data.Can.Microlens: _Eno :: Traversal' (Can a b) b
+ Data.Can.Microlens: _Eno :: forall a b f. Applicative f => (b -> f b) -> Can a b -> f (Can a b)
- Data.Can.Microlens: _Non :: Traversal' (Can a b) ()
+ Data.Can.Microlens: _Non :: forall a b f. Applicative f => (() -> f ()) -> Can a b -> f (Can a b)
- Data.Can.Microlens: _One :: Traversal' (Can a b) a
+ Data.Can.Microlens: _One :: forall a b f. Applicative f => (a -> f a) -> Can a b -> f (Can a b)
- Data.Can.Microlens: _Two :: Traversal' (Can a b) (a, b)
+ Data.Can.Microlens: _Two :: forall a b f. Applicative f => ((a, b) -> f (a, b)) -> Can a b -> f (Can a b)
- Data.Can.Microlens: enoing :: Traversal (Can a b) (Can a c) b c
+ Data.Can.Microlens: enoing :: forall a b c f. Applicative f => (b -> f c) -> Can a b -> f (Can a c)
- Data.Can.Microlens: oneing :: Traversal (Can a c) (Can b c) a b
+ Data.Can.Microlens: oneing :: forall a c b f. Applicative f => (a -> f b) -> Can a c -> f (Can b c)
- Data.Can.Microlens: twoed :: Traversal' (Can a b) (a, b)
+ Data.Can.Microlens: twoed :: forall a b f. Applicative f => ((a, b) -> f (a, b)) -> Can a b -> f (Can a b)
- Data.Can.Microlens: twoing :: Traversal (Can a a) (Can b b) a b
+ Data.Can.Microlens: twoing :: forall a b f. Applicative f => (a -> f b) -> Can a a -> f (Can b b)
- Data.Smash.Microlens: _Nada :: Traversal' (Smash a b) ()
+ Data.Smash.Microlens: _Nada :: forall a b f. Applicative f => (() -> f ()) -> Smash a b -> f (Smash a b)
- Data.Smash.Microlens: _Smash :: Traversal' (Smash a b) (a, b)
+ Data.Smash.Microlens: _Smash :: forall a b f. Applicative f => ((a, b) -> f (a, b)) -> Smash a b -> f (Smash a b)
- Data.Smash.Microlens: smashed :: Traversal (Smash a b) (Smash c d) (a, b) (c, d)
+ Data.Smash.Microlens: smashed :: forall a b c d f. Applicative f => ((a, b) -> f (c, d)) -> Smash a b -> f (Smash c d)
- Data.Smash.Microlens: smashing :: Traversal (Smash a a) (Smash b b) a b
+ Data.Smash.Microlens: smashing :: forall a b f. Applicative f => (a -> f b) -> Smash a a -> f (Smash b b)
- Data.Wedge.Microlens: _Here :: Traversal (Wedge a b) (Wedge c b) a c
+ Data.Wedge.Microlens: _Here :: forall a b c f. Applicative f => (a -> f c) -> Wedge a b -> f (Wedge c b)
- Data.Wedge.Microlens: _Nowhere :: Traversal' (Wedge a b) ()
+ Data.Wedge.Microlens: _Nowhere :: forall a b f. Applicative f => (() -> f ()) -> Wedge a b -> f (Wedge a b)
- Data.Wedge.Microlens: _There :: Traversal (Wedge a b) (Wedge a d) b d
+ Data.Wedge.Microlens: _There :: forall a b d f. Applicative f => (b -> f d) -> Wedge a b -> f (Wedge a d)
- Data.Wedge.Microlens: here :: Traversal' (Wedge a b) a
+ Data.Wedge.Microlens: here :: forall a b f. Applicative f => (a -> f a) -> Wedge a b -> f (Wedge a b)
- Data.Wedge.Microlens: there :: Traversal' (Wedge a b) b
+ Data.Wedge.Microlens: there :: forall a b f. Applicative f => (b -> f b) -> Wedge a b -> f (Wedge a b)

Files

CHANGELOG.md view
@@ -1,5 +1,16 @@ # Revision history for smash-microlens +## 0.2.0 -- 2026-10-26++* Start the `0.2` major release series and require `smash >=0.2.0 && <0.3`.+* Preserve the existing optics API and traversal behavior.++## 0.1.0.3 -- 2026-10-26++* Update dependency bounds and the supported GHC matrix to 9.6–9.14.+* Update copyrights through 2026.+* Add Tasty unit and property tests for constructor selection and traversal laws.+ ## 0.1.0.2 -- 2022-04-03  * Update `base` bounds to allow GHC 9.2.x
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2020, Emily Pillmore+Copyright (c) 2020-2026, Emily Pillmore  All rights reserved. 
README.md view
@@ -1,7 +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)+[![CI](https://github.com/emilypi/smash/actions/workflows/haskell-ci.yml/badge.svg)](https://github.com/emilypi/smash/actions/workflows/haskell-ci.yml) [![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).
smash-microlens.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.0 name:               smash-microlens-version:            0.1.0.2+version:            0.2.0 synopsis:           Optics for the `smash` library description:        Optics for the `smash` library using `microlens` homepage:           https://github.com/emilypi/smash@@ -9,19 +9,19 @@ license-file:       LICENSE author:             Emily Pillmore maintainer:         emilypi@cohomolo.gy-copyright:          (c) 2020-2022 Emily Pillmore <emilypi@cohomolo.gy>+copyright:          (c) 2020-2026 Emily Pillmore <emilypi@cohomolo.gy> category:           Data build-type:         Simple-extra-source-files:+extra-doc-files:   CHANGELOG.md   README.md  tested-with:-  GHC ==8.6.5-   || ==8.8.4-   || ==8.10.7-   || ==9.0.2-   || ==9.2.2+  GHC ==9.6.7+   || ==9.8.4+   || ==9.10.3+   || ==9.12.4+   || ==9.14.1  source-repository head   type:     git@@ -33,20 +33,30 @@     Data.Smash.Microlens     Data.Wedge.Microlens -  -- other-modules:-  -- other-extensions:   build-depends:-      base       >=4.11 && <4.17-    , microlens  >=0.3  && <0.5-    , smash      >=0.1.3+      base              >=4.15 && <4.23+    , microlens         >=0.3  && <0.6+    , smash             >=0.2.0 && <0.3 +   hs-source-dirs:   src   default-language: Haskell2010   ghc-options:      -Wall -test-suite smash-microlens-test++test-suite smash-microlens-tests   default-language: Haskell2010   type:             exitcode-stdio-1.0-  hs-source-dirs:   test-  main-is:          MyLibTest.hs-  build-depends:    base >=4.10 && <5.0+  hs-source-dirs:    test+  main-is:          Main.hs+  build-depends:+      base              >=4.15 && <4.23+    , smash-microlens+    , tasty             >=1.4 && <1.6+    , tasty-hunit       >=0.10 && <0.11+    , tasty-quickcheck  >=0.10 && <0.12+    , QuickCheck        >=2.14 && <2.17+    , smash             >=0.2.0 && <0.3+    , microlens++  ghc-options:      -Wall -threaded -rtsopts -with-rtsopts=-N
src/Data/Can/Microlens.hs view
@@ -6,7 +6,7 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} -- | -- Module       : Data.Can.Microlens--- Copyright 	: (c) 2020-2022 Emily Pillmore+-- Copyright 	: (c) 2020-2026 Emily Pillmore -- License	: BSD-style -- -- Maintainer	: Emily Pillmore <emilypi@cohomolo.gy>
src/Data/Smash/Microlens.hs view
@@ -6,7 +6,7 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} -- | -- Module       : Data.Smash.Microlens--- Copyright 	: (c) 2020-2022 Emily Pillmore+-- Copyright 	: (c) 2020-2026 Emily Pillmore -- License	: BSD-style -- -- Maintainer	: Emily Pillmore <emilypi@cohomolo.gy>
src/Data/Wedge/Microlens.hs view
@@ -6,7 +6,7 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} -- | -- Module       : Data.Wedge.Microlens--- Copyright 	: (c) 2020-2022 Emily Pillmore+-- Copyright 	: (c) 2020-2026 Emily Pillmore -- License	: BSD-style -- -- Maintainer	: Emily Pillmore <emilypi@cohomolo.gy>
+ test/Main.hs view
@@ -0,0 +1,80 @@+{-# LANGUAGE ScopedTypeVariables #-}+-- Copyright (c) 2020-2026 Emily Pillmore+module Main (main) where++import Data.Bifunctor (bimap)+import Data.Can+import Data.Can.Microlens+import Data.Smash+import Data.Smash.Microlens+import Data.Wedge+import Data.Wedge.Microlens+import Lens.Micro+import Test.Tasty+import Test.Tasty.HUnit+import Test.Tasty.QuickCheck++main :: IO ()+main = defaultMain $ testGroup "smash-microlens"+  [ testGroup "Constructor selection"+    [ testCase "Can constructors select only their exact branch" $ do+        map (\x -> x ^? _Non) cs @?= [Just (), Nothing, Nothing, Nothing]+        map (\x -> x ^? _One) cs @?= [Nothing, Just 1, Nothing, Nothing]+        map (\x -> x ^? _Eno) cs @?= [Nothing, Nothing, Just 2, Nothing]+        map (\x -> x ^? _Two) cs @?= [Nothing, Nothing, Nothing, Just (1,2)]+    , testCase "Smash constructors select only their exact branch" $ do+        map (\x -> x ^? _Nada) ss @?= [Just (), Nothing]+        map (\x -> x ^? _Smash) ss @?= [Nothing, Just (1,2)]+    , testCase "Wedge constructors select only their exact branch" $ do+        map (\x -> x ^? _Nowhere) ws @?= [Just (), Nothing, Nothing]+        map (\x -> x ^? _Here) ws @?= [Nothing, Just 1, Nothing]+        map (\x -> x ^? _There) ws @?= [Nothing, Nothing, Just 2]+    , testCase "pair traversals preserve unmatched branches" $ do+        map (over twoed (\(a,b) -> (a+10,b+20))) cs @?= [Non, One 1, Eno 2, Two 11 22]+        map (over smashed (\(a,b) -> (a+10,b+20))) ss @?= [Nada, Smash 11 22]+    , testCase "type-changing traversals preserve the other payload" $ do+        over oneing show (Two (1 :: Int) True) @?= Two "1" True+        over enoing show (Two True (2 :: Int)) @?= Two True "2"+        over _Here show (Here (1 :: Int) :: Wedge Int Bool) @?= Here "1"+        over _There show (There (2 :: Int) :: Wedge Bool Int) @?= There "2"+    ]+  , testGroup "Traversal properties"+    [ testProperty "Can left traversal agrees with bimap" $ \a b (Fun _ f :: Fun Int Int) ->+        conjoin [over oneing f x === bimap f id x | x <- canValues a b]+    , testProperty "Can right traversal agrees with bimap" $ \a b (Fun _ f :: Fun Int Int) ->+        conjoin [over enoing f x === bimap id f x | x <- canValues a b]+    , testProperty "Can both traversal agrees with bimap" $ \a b (Fun _ f :: Fun Int Int) ->+        conjoin [over twoing f x === bimap f f x | x <- canValues a b]+    , testProperty "Smash traversal agrees with bimap" $ \a b (Fun _ f :: Fun Int Int) ->+        conjoin [over smashing f x === bimap f f x | x <- smashValues a b]+    , testProperty "Wedge traversals agree with bimap" $ \a b (Fun _ f :: Fun Int Int) ->+        conjoin [over here f x === bimap f id x .&&. over there f x === bimap id f x | x <- wedgeValues a b]+    , testProperty "Can traversal identity" $ \a b ->+        conjoin [over twoing id x === x | x <- canValues a b]+    , testProperty "Smash traversal identity" $ \a b ->+        conjoin [over smashing id x === x | x <- smashValues a b]+    , testProperty "Wedge traversal identity" $ \a b ->+        conjoin [over here id x === x .&&. over there id x === x | x <- wedgeValues a b]+    , testProperty "Can traversal composition" $ \a b (Fun _ f :: Fun Int Int) (Fun _ g :: Fun Int Int) ->+        conjoin [over twoing f (over twoing g x) === over twoing (f . g) x | x <- canValues a b]+    , testProperty "Smash traversal composition" $ \a b (Fun _ f :: Fun Int Int) (Fun _ g :: Fun Int Int) ->+        conjoin [over smashing f (over smashing g x) === over smashing (f . g) x | x <- smashValues a b]+    , testProperty "Wedge traversal composition" $ \a b (Fun _ f :: Fun Int Int) (Fun _ g :: Fun Int Int) ->+        conjoin [over here f (over here g x) === over here (f . g) x .&&.+                 over there f (over there g x) === over there (f . g) x | x <- wedgeValues a b]+    ]++  ]+  where+    cs = canValues 1 2+    ss = smashValues 1 2+    ws = wedgeValues 1 2++canValues :: Int -> Int -> [Can Int Int]+canValues a b = [Non, One a, Eno b, Two a b]++smashValues :: Int -> Int -> [Smash Int Int]+smashValues a b = [Nada, Smash a b]++wedgeValues :: Int -> Int -> [Wedge Int Int]+wedgeValues a b = [Nowhere, Here a, There b]
− test/MyLibTest.hs
@@ -1,4 +0,0 @@-module Main (main) where--main :: IO ()-main = putStrLn "Test suite not yet implemented."