packages feed

microlens 0.4.11.2 → 0.4.12.0

raw patch · 4 files changed

+83/−45 lines, 4 files

Files

CHANGELOG.md view
@@ -1,3 +1,11 @@+# 0.4.12.0++* Added instance `Ixed (NonEmpty a)` for GHC >= 8.++# 0.4.11.3++* Exported a `coerce` compatibility shim from `Lens.Micro.Internal`.+ # 0.4.11.2  * Fixed compilation on GHC 8.8 (thanks to @vmchale).
microlens.cabal view
@@ -1,5 +1,5 @@ name:                microlens-version:             0.4.11.2+version:             0.4.12.0 synopsis:            A tiny lens library with no dependencies description:   NOTE: If you're writing an app, you probably want <http://hackage.haskell.org/package/microlens-platform microlens-platform> – it has the most features. <http://hackage.haskell.org/package/microlens microlens> is intended more for library writers who want a tiny lens library (after all, lenses are pretty useful for everything, not just for updating records!).@@ -48,7 +48,9 @@                      GHC==8.0.2                      GHC==8.2.2                      GHC==8.4.4-                     GHC==8.6.4+                     GHC==8.6.5+                     GHC==8.8.1+                     GHC==8.10.1  source-repository head   type:                git
src/Lens/Micro.hs view
@@ -116,12 +116,6 @@ import Data.Tuple import qualified Data.Foldable as F -#if __GLASGOW_HASKELL__ >= 708-import Data.Coerce-#else-import Unsafe.Coerce-#endif- #if MIN_VERSION_base(4,8,0) import Data.Function ((&)) #endif@@ -1059,13 +1053,8 @@   where     Bazaar b = l sell s     sell w = Bazaar ($ w)-#if __GLASGOW_HASKELL__ >= 708     ins f = (coerce :: [Identity a] -> [a])               (getConst (f (\ra -> Const [Identity ra])))-#else-    ins f = (unsafeCoerce :: [Identity a] -> [a])-              (getConst (f (\ra -> Const [Identity ra])))-#endif     unsafeOuts f = evalState (f (\_ -> state (unconsWithDefault fakeVal)))       where fakeVal = error "unsafeOuts: not enough elements were supplied"     unconsWithDefault d []     = (d,[])
src/Lens/Micro/Internal.hs view
@@ -11,7 +11,7 @@ {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE ImplicitParams #-} --- Note: this module is marked 'Unsafe' because it exports (#.), which is essentially 'coerce', and Data.Coerce is marked 'Unsafe' in base. As per <https://github.com/ekmett/lens/issues/661>, this is an issue for 'lens' as well but they have opted for 'Trustworthy' instead.+-- Note: this module is marked 'Unsafe' because it exports 'coerce', and Data.Coerce is marked 'Unsafe' in base. As per <https://github.com/ekmett/lens/issues/661>, this is an issue for 'lens' as well but they have opted for 'Trustworthy' instead. {-# LANGUAGE Unsafe #-}  {- |@@ -36,8 +36,6 @@   foldrOf,   foldMapOf,   sets,-  ( #. ),-  ( .# ),   phantom,   Each(..),   Index,@@ -56,6 +54,13 @@    -- * CallStack   HasCallStack,++  -- * Coerce compatibility shim+  coerce,++  -- * Coerce-like composition+  ( #. ),+  ( .# ), ) where @@ -69,7 +74,7 @@ import Data.Complex  #if __GLASGOW_HASKELL__ >= 800-import Data.List.NonEmpty (NonEmpty)+import Data.List.NonEmpty (NonEmpty(..)) #endif  #if __GLASGOW_HASKELL__ < 710@@ -154,34 +159,6 @@ {-# INLINE noEffect #-}  --------------------------------------------------------------------------------- Data.Profunctor.Unsafe----------------------------------------------------------------------------------- Note: 'lens' defines a type-restricted version of (#.) to work around a--- bug, but our version is restricted enough that we don't need it. See--- <https://github.com/ekmett/lens/commit/cde2fc39c0dba413d1a6f814b47bd14431a5e339>--#if __GLASGOW_HASKELL__ >= 708-( #. ) :: Coercible c b => (b -> c) -> (a -> b) -> (a -> c)-( #. ) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b--( .# ) :: Coercible b a => (b -> c) -> (a -> b) -> (a -> c)-( .# ) pbc _ = coerce pbc-#else-( #. ) :: (b -> c) -> (a -> b) -> (a -> c)-( #. ) _ = unsafeCoerce--( .# ) :: (b -> c) -> (a -> b) -> (a -> c)-( .# ) pbc _ = unsafeCoerce pbc-#endif--{-# INLINE ( #. ) #-}-{-# INLINE ( .# ) #-}--infixr 9 #.-infixl 8 .#-------------------------------------------------------------------------------- -- classes ------------------------------------------------------------------------------ @@ -270,6 +247,11 @@ type instance Index   [a] = Int type instance IxValue [a] = a +#if __GLASGOW_HASKELL__ >= 800+type instance Index   (NonEmpty a) = Int+type instance IxValue (NonEmpty a) = a+#endif+ class Ixed m where   {- | This traversal lets you access (and update) an arbitrary element in a list, array, @Map@, etc. (If you want to insert or delete elements as well, look at 'at'.)@@ -297,12 +279,22 @@  The following instances are provided in this package: +#if __GLASGOW_HASKELL__ >= 800 @ 'ix' :: 'Int' -> 'Traversal'' [a] a +'ix' :: 'Int' -> 'Traversal'' (NonEmpty a) a+ 'ix' :: ('Eq' e) => e -> 'Traversal'' (e -> a) a @+#else+@+'ix' :: 'Int' -> 'Traversal'' [a] a +'ix' :: ('Eq' e) => e -> 'Traversal'' (e -> a) a+@+#endif+ You can also use 'ix' with types from <http://hackage.haskell.org/package/array array>, <http://hackage.haskell.org/package/bytestring bytestring>, and <http://hackage.haskell.org/package/containers containers> by using <http://hackage.haskell.org/package/microlens-ghc microlens-ghc>, or additionally with types from <http://hackage.haskell.org/package/vector vector>, <http://hackage.haskell.org/package/text text>, and <http://hackage.haskell.org/package/unordered-containers unordered-containers> by using <http://hackage.haskell.org/package/microlens-platform microlens-platform>.   -}   ix :: Index m -> Traversal' m (IxValue m)@@ -360,6 +352,15 @@     go (a:as) i = (a:) <$> (go as $! i - 1)   {-# INLINE ix #-} +#if __GLASGOW_HASKELL__ >= 800+instance Ixed (NonEmpty a) where+  ix k f xs0 | k < 0 = pure xs0+             | otherwise = go xs0 k where+    go (a:|as) 0 = (:|as) <$> f a+    go (a:|as) i = (a:|) <$> ix (i - 1) f as+  {-# INLINE ix #-}+#endif+ class Field1 s t a b | s -> a, t -> b, s b -> t, t a -> s where   {- | Gives access to the 1st field of a tuple (up to 5-tuples).@@ -618,3 +619,41 @@ "hello" :: Lazy.Text   -}   lazy   :: Lens' strict lazy++----------------------------------------------------------------------------+-- Coerce compatibility shim+----------------------------------------------------------------------------++#if __GLASGOW_HASKELL__ < 708+coerce :: a -> b+coerce = unsafeCoerce+{-# INLINE coerce #-}+#endif++----------------------------------------------------------------------------+-- Coerce-like composition+----------------------------------------------------------------------------++-- Note: 'lens' defines a type-restricted version of (#.) to work around a+-- bug, but our version is restricted enough that we don't need it. See+-- <https://github.com/ekmett/lens/commit/cde2fc39c0dba413d1a6f814b47bd14431a5e339>++#if __GLASGOW_HASKELL__ >= 708+( #. ) :: Coercible c b => (b -> c) -> (a -> b) -> (a -> c)+( #. ) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b++( .# ) :: Coercible b a => (b -> c) -> (a -> b) -> (a -> c)+( .# ) pbc _ = coerce pbc+#else+( #. ) :: (b -> c) -> (a -> b) -> (a -> c)+( #. ) _ = unsafeCoerce++( .# ) :: (b -> c) -> (a -> b) -> (a -> c)+( .# ) pbc _ = unsafeCoerce pbc+#endif++{-# INLINE ( #. ) #-}+{-# INLINE ( .# ) #-}++infixr 9 #.+infixl 8 .#