From 3f25838f524b18d6e18431baeae2163ea6d9595a Mon Sep 17 00:00:00 2001 From: stevenfontanella Date: Sun, 4 Feb 2024 22:08:14 -0800 Subject: [PATCH] Migrate Lens.Micro.ProCompat into Lens.Micro.Pro Fixes #177. See https://github.com/stevenfontanella/microlens/pull/174#issuecomment-1925591528 for rationale. --- microlens-pro/CHANGELOG.md | 9 ++++++-- microlens-pro/microlens-pro.cabal | 3 +-- microlens-pro/src/Lens/Micro/Pro.hs | 28 +++++++++++++++-------- microlens-pro/src/Lens/Micro/Pro/TH.hs | 2 -- microlens-pro/src/Lens/Micro/ProCompat.hs | 23 ------------------- 5 files changed, 26 insertions(+), 39 deletions(-) delete mode 100644 microlens-pro/src/Lens/Micro/ProCompat.hs diff --git a/microlens-pro/CHANGELOG.md b/microlens-pro/CHANGELOG.md index 0221c5b..eb66689 100644 --- a/microlens-pro/CHANGELOG.md +++ b/microlens-pro/CHANGELOG.md @@ -1,3 +1,8 @@ -# 0.1.0.0 +# 0.2.0 -[#105](https://github.com/stevenfontanella/microlens/issues/105) microlens-pro initial release, with `Prism`s and `Iso`s. +* New major release. +* [#177](https://github.com/stevenfontanella/microlens/issues/177) Moves `Lens.Micro.ProCompat` into `Lens.Micro.Pro`. + +# 0.1.0 + +* [#105](https://github.com/stevenfontanella/microlens/issues/105) microlens-pro initial release, with `Prism`s and `Iso`s. diff --git a/microlens-pro/microlens-pro.cabal b/microlens-pro/microlens-pro.cabal index 55f0ee2..6b55e15 100644 --- a/microlens-pro/microlens-pro.cabal +++ b/microlens-pro/microlens-pro.cabal @@ -1,5 +1,5 @@ name: microlens-pro -version: 0.1.0 +version: 0.2.0 synopsis: Prisms and isomorphisms for microlens description: This package provides lens-compatible 'Prism' and 'Iso'. Consequently, it @@ -47,7 +47,6 @@ source-repository head library exposed-modules: Lens.Micro.Pro - Lens.Micro.ProCompat Lens.Micro.Pro.TH Lens.Micro.Pro.Internal Lens.Micro.Pro.Type diff --git a/microlens-pro/src/Lens/Micro/Pro.hs b/microlens-pro/src/Lens/Micro/Pro.hs index f64a3f6..23987af 100644 --- a/microlens-pro/src/Lens/Micro/Pro.hs +++ b/microlens-pro/src/Lens/Micro/Pro.hs @@ -7,9 +7,9 @@ This module is home to lens definitions that require [profunctors](https://hackage.haskell.org/package/profunctors), most notably 'Iso' and 'Prism'. Depending on 'profunctors' is quite the to bear — one that includes all dependencies of @microlens-platform@. For this reason, -@microlens-pro@ ships with a compatiblity module "Lens.Micro.ProCompat" which -re-exports the entirety of "Lens.Micro.Platform", but with the profunctor-less -definitions hidden and overridden with profunctor'd definitions from this module. +@microlens-pro@ re-exports the entirety of "Lens.Micro.Platform", but +with the profunctor-less definitions hidden and overridden with profunctor'd +definitions from this module. -} {-# LANGUAGE DefaultSignatures #-} @@ -66,10 +66,11 @@ module Lens.Micro.Pro , review , (#) , unto + + , module Lens.Micro.Platform ) where -------------------------------------------------------------------------------- -import Lens.Micro (has) import Lens.Micro.Contra import Lens.Micro.Pro.Type import Lens.Micro.Pro.Internal @@ -89,6 +90,12 @@ import Data.Profunctor.Unsafe import GHC.Exts (TYPE) #endif +-- For re-export hiding conflicting names +import Lens.Micro.Platform hiding + ( _Left, _Right, _Just, _Nothing, _Show + , strict, lazy, packed, unpacked, non + ) + -- implement instances import qualified Data.Text as Text import qualified Data.Text.Lazy as Text.Lazy @@ -154,8 +161,8 @@ them share names with the lens-__incompatible__ definitions from [Lens.Micro](https://hackage.haskell.org/package/microlens-0.4.13.1/docs/Lens-Micro.html#g:5) and [Lens.Micro.Platform](https://hackage.haskell.org/package/microlens-platform-0.4.3.4/docs/Lens-Micro-Platform.html). -For convenience, we provide a module "Lens.Micro.ProCompat" which emulates -Lens.Micro.Platform, but uses the lens-compatible isos. +For convenience, we re-export Lens.Micro.Platform, but with non-lens-compatible +isos hidden and replaced with lens-compatbile ones. -} @@ -664,7 +671,7 @@ Just "hello worms" -} re :: AReview t b -> Getter b t -re p = to (runIdentity #. unTagged #. p .# Tagged .# Identity) +re p = toInternal (runIdentity #. unTagged #. p .# Tagged .# Identity) {-# INLINE re #-} @@ -675,16 +682,17 @@ re p = to (runIdentity #. unTagged #. p .# Tagged .# Identity) infixr 8 # {-# INLINE (#) #-} +-- Not exported -- TODO: `to` is temporarily defined here. This should be in microlens-contra, -- or better yet, microlens as Contravariant has been in base since at least ghc -- 8.6.5. This definition isn't perfect either -- the version from lens is: -- -- to :: (Profunctor p, Contravariant f) => (s -> a) -> Optic' p f s a -to :: (s -> a) -> Getter s a -to k = dimap k (contramap k) +toInternal :: (s -> a) -> Getter s a +toInternal k = dimap k (contramap k) -{-# INLINE to #-} +{-# INLINE toInternal #-} {- | Construct a 'Review' out of a constructor. Consider this more pleasant type diff --git a/microlens-pro/src/Lens/Micro/Pro/TH.hs b/microlens-pro/src/Lens/Micro/Pro/TH.hs index 69dfaf1..4c37c05 100644 --- a/microlens-pro/src/Lens/Micro/Pro/TH.hs +++ b/microlens-pro/src/Lens/Micro/Pro/TH.hs @@ -25,8 +25,6 @@ module Lens.Micro.Pro.TH ) where -import Lens.Micro -import Lens.Micro.Extras import Lens.Micro.Pro import Lens.Micro.TH.Internal (HasTypeVars(..), typeVars, substTypeVars, newNames, conAppsT, inlinePragma) diff --git a/microlens-pro/src/Lens/Micro/ProCompat.hs b/microlens-pro/src/Lens/Micro/ProCompat.hs deleted file mode 100644 index ed24d8c..0000000 --- a/microlens-pro/src/Lens/Micro/ProCompat.hs +++ /dev/null @@ -1,23 +0,0 @@ -{- | -Module : Lens.Micro.ProCompat -Copyright : (C) 2013-2016 Edward Kmett, 2018 Monadfix -License : BSD-style (see the file LICENSE) - -This module re-exports "Lens.Micro.Platform", overriding definitions where -necesarry. --} -module Lens.Micro.ProCompat - ( module Lens.Micro.Platform - , module Lens.Micro.Pro - ) - where --------------------------------------------------------------------------------- - --- everything hidden here is redefined in 'Lens.Micro.Pro' -import Lens.Micro.Platform hiding - ( _Left, _Right, _Just, _Nothing, _Show - , strict, lazy, packed, unpacked - , non - ) -import Lens.Micro.Pro -