packages feed

lens 4.11.1 → 4.12

raw patch · 15 files changed

+116/−218 lines, 15 filesdep ~reflection

Dependency ranges changed: reflection

Files

CHANGELOG.markdown view
@@ -1,3 +1,11 @@+4.12+----+* `reflection 2` support.++4.11.2+------+* Give `cosmosOn` a more general type.+ 4.11.1 ------ * Added `cosmos`, `cosmosOf`, `cosmosOn`, `cosmosOnOf` to `Control.Lens.Plated`.
lens.cabal view
@@ -1,6 +1,6 @@ name:          lens category:      Data, Lenses, Generics-version:       4.11.1+version:       4.12 license:       BSD3 cabal-version: >= 1.8 license-file:  LICENSE@@ -199,7 +199,7 @@     mtl                       >= 2.0.1    && < 2.3,     parallel                  >= 3.1.0.1  && < 3.3,     profunctors               >= 5        && < 6,-    reflection                >= 1.1.6    && < 2,+    reflection                >= 2        && < 3,     semigroupoids             >= 5        && < 6,     semigroups                >= 0.8.4    && < 1,     tagged                    >= 0.4.4    && < 1,@@ -242,7 +242,6 @@     Control.Lens.Internal.List     Control.Lens.Internal.Magma     Control.Lens.Internal.Prism-    Control.Lens.Internal.Reflection     Control.Lens.Internal.Review     Control.Lens.Internal.Setter     Control.Lens.Internal.TH
− lens.sig

binary file changed (543 → absent bytes)

src/Control/Lens/At.hs view
@@ -14,6 +14,10 @@ {-# LANGUAGE Trustworthy #-} #endif +#if __GLASGOW_HASKELL__ >= 711+{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}+#endif+ #ifndef MIN_VERSION_base #define MIN_VERSION_base(x,y,z) 1 #endif
src/Control/Lens/Indexed.hs view
@@ -12,6 +12,10 @@ {-# LANGUAGE Trustworthy #-} -- vector, hashable #endif +#if __GLASGOW_HASKELL__ >= 711+{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}+#endif+ #ifndef MIN_VERSION_containers #define MIN_VERSION_containers(x,y,z) 1 #endif
src/Control/Lens/Internal/Bazaar.hs view
@@ -7,6 +7,10 @@ #if __GLASGOW_HASKELL__ >= 707 {-# LANGUAGE RoleAnnotations #-} #endif+#if __GLASGOW_HASKELL__ >= 711+{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}+#endif+ ----------------------------------------------------------------------------- -- | -- Module      :  Control.Lens.Internal.Bazaar
src/Control/Lens/Internal/Context.hs view
@@ -9,6 +9,9 @@ #if __GLASGOW_HASKELL__ >= 707 {-# LANGUAGE RoleAnnotations #-} #endif+#if __GLASGOW_HASKELL__ >= 711+{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}+#endif ----------------------------------------------------------------------------- -- | -- Module      :  Control.Lens.Internal.Context
src/Control/Lens/Internal/Exception.hs view
@@ -36,10 +36,10 @@ import Control.Exception as Exception import Control.Lens.Fold import Control.Lens.Getter-import Control.Lens.Internal.Reflection import Control.Monad.Catch as Catch import Data.Monoid import Data.Proxy+import Data.Reflection import Data.Typeable  -- This is needed because ghc 7.8-rc2 has Typeable1 as a type alias.
src/Control/Lens/Internal/Fold.hs view
@@ -2,6 +2,10 @@ {-# LANGUAGE Rank2Types #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE UndecidableInstances #-}+#if __GLASGOW_HASKELL__ >= 711+{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}+#endif+ ----------------------------------------------------------------------------- -- | -- Module      :  Control.Lens.Internal.Fold@@ -35,7 +39,9 @@ import Data.Reflection import Prelude +#ifdef HLINT {-# ANN module "HLint: ignore Avoid lambda" #-}+#endif  ------------------------------------------------------------------------------ -- Folding
src/Control/Lens/Internal/Magma.hs view
@@ -196,7 +196,7 @@  instance Bizarre (Indexed Int) Mafic where   bazaar (pafb :: Indexed Int a (f b)) (Mafic _ k) = go (k 0) where-    go :: Applicative f => Magma Int t b a -> f t+    go :: Magma Int t b a -> f t     go (MagmaAp x y)   = go x <*> go y     go (MagmaFmap f x) = f <$> go x     go (MagmaPure x)   = pure x@@ -244,7 +244,7 @@  instance Corepresentable p => Bizarre p (TakingWhile p g) where   bazaar (pafb :: p a (f b)) ~(TakingWhile _ _ k) = go (k True) where-    go :: Applicative f => Magma () t b (Corep p a) -> f t+    go :: Magma () t b (Corep p a) -> f t     go (MagmaAp x y)  = go x <*> go y     go (MagmaFmap f x)  = f <$> go x     go (MagmaPure x)    = pure x
− src/Control/Lens/Internal/Reflection.hs
@@ -1,209 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE Rank2Types #-}-{-# LANGUAGE Trustworthy #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE UndecidableInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# OPTIONS_GHC -fno-cse #-}-{-# OPTIONS_GHC -fno-full-laziness #-}-{-# OPTIONS_GHC -fno-float-in #-}-{-# OPTIONS_GHC -fno-warn-unused-binds #-}--#ifndef MIN_VERSION_base-#define MIN_VERSION_base(x,y,z) 1-#endif--------------------------------------------------------------------------------- |--- Module     : Control.Lens.Internal.Reflection--- Copyright  : 2009-2015 Edward Kmett,---              2012 Elliott Hird,---              2004 Oleg Kiselyov and Chung-chieh Shan--- License    : BSD3------ Maintainer  : Edward Kmett <ekmett@gmail.com>--- Stability   : experimental--- Portability : non-portable------ Reifies arbitrary terms at the type level. Based on the Functional--- Pearl: Implicit Configurations paper by Oleg Kiselyov and--- Chung-chieh Shan.------ <http://www.cs.rutgers.edu/~ccshan/prepose/prepose.pdf>------ The approach from the paper was modified to work with Data.Proxy--- and streamline the API by Edward Kmett and Elliott Hird.------ Usage comes down to two combinators, 'reify' and 'reflect'.------ >>> reify 6 (\p -> reflect p + reflect p)--- 12------ The argument passed along by reify is just a @data 'Proxy' t =--- Proxy@, so all of the information needed to reconstruct your value--- has been moved to the type level.  This enables it to be used when--- constructing instances (see @examples/Monoid.hs@).------ This version is based on the \"slow\" path from the @reflection@ package,--- but modified to work with the same 'Reifies' class as is provided by the \"fast\"--- path, and to make sure the parameter is 'Typeable'.------ This is necessary to work around the changes to @Data.Typeable@ in GHC HEAD.----------------------------------------------------------------------------------module Control.Lens.Internal.Reflection-    (-      Reifies(..)-    , reifyTypeable-    ) where--import Foreign.Ptr-import Foreign.StablePtr-import System.IO.Unsafe-import Data.Proxy-import Data.Bits-import Data.Word-import Data.Typeable-import Data.Reflection--#if !MIN_VERSION_base(4,8,0)-import Control.Applicative-#endif--#ifdef HLINT-{-# ANN module "HLint: ignore Avoid lambda" #-}-#endif--class Typeable s => B s where-  reflectByte :: proxy s -> IntPtr--#define BYTES(GO) \-  GO(T0,0) GO(T1,1) GO(T2,2) GO(T3,3) GO(T4,4) GO(T5,5) GO(T6,6) GO(T7,7) GO(T8,8) GO(T9,9) GO(T10,10) GO(T11,11) \-  GO(T12,12) GO(T13,13) GO(T14,14) GO(T15,15) GO(T16,16) GO(T17,17) GO(T18,18) GO(T19,19) GO(T20,20) GO(T21,21) GO(T22,22) \-  GO(T23,23) GO(T24,24) GO(T25,25) GO(T26,26) GO(T27,27) GO(T28,28) GO(T29,29) GO(T30,30) GO(T31,31) GO(T32,32) GO(T33,33) \-  GO(T34,34) GO(T35,35) GO(T36,36) GO(T37,37) GO(T38,38) GO(T39,39) GO(T40,40) GO(T41,41) GO(T42,42) GO(T43,43) GO(T44,44) \-  GO(T45,45) GO(T46,46) GO(T47,47) GO(T48,48) GO(T49,49) GO(T50,50) GO(T51,51) GO(T52,52) GO(T53,53) GO(T54,54) GO(T55,55) \-  GO(T56,56) GO(T57,57) GO(T58,58) GO(T59,59) GO(T60,60) GO(T61,61) GO(T62,62) GO(T63,63) GO(T64,64) GO(T65,65) GO(T66,66) \-  GO(T67,67) GO(T68,68) GO(T69,69) GO(T70,70) GO(T71,71) GO(T72,72) GO(T73,73) GO(T74,74) GO(T75,75) GO(T76,76) GO(T77,77) \-  GO(T78,78) GO(T79,79) GO(T80,80) GO(T81,81) GO(T82,82) GO(T83,83) GO(T84,84) GO(T85,85) GO(T86,86) GO(T87,87) GO(T88,88) \-  GO(T89,89) GO(T90,90) GO(T91,91) GO(T92,92) GO(T93,93) GO(T94,94) GO(T95,95) GO(T96,96) GO(T97,97) GO(T98,98) GO(T99,99) \-  GO(T100,100) GO(T101,101) GO(T102,102) GO(T103,103) GO(T104,104) GO(T105,105) GO(T106,106) GO(T107,107) GO(T108,108) \-  GO(T109,109) GO(T110,110) GO(T111,111) GO(T112,112) GO(T113,113) GO(T114,114) GO(T115,115) GO(T116,116) GO(T117,117) \-  GO(T118,118) GO(T119,119) GO(T120,120) GO(T121,121) GO(T122,122) GO(T123,123) GO(T124,124) GO(T125,125) GO(T126,126) \-  GO(T127,127) GO(T128,128) GO(T129,129) GO(T130,130) GO(T131,131) GO(T132,132) GO(T133,133) GO(T134,134) GO(T135,135) \-  GO(T136,136) GO(T137,137) GO(T138,138) GO(T139,139) GO(T140,140) GO(T141,141) GO(T142,142) GO(T143,143) GO(T144,144) \-  GO(T145,145) GO(T146,146) GO(T147,147) GO(T148,148) GO(T149,149) GO(T150,150) GO(T151,151) GO(T152,152) GO(T153,153) \-  GO(T154,154) GO(T155,155) GO(T156,156) GO(T157,157) GO(T158,158) GO(T159,159) GO(T160,160) GO(T161,161) GO(T162,162) \-  GO(T163,163) GO(T164,164) GO(T165,165) GO(T166,166) GO(T167,167) GO(T168,168) GO(T169,169) GO(T170,170) GO(T171,171) \-  GO(T172,172) GO(T173,173) GO(T174,174) GO(T175,175) GO(T176,176) GO(T177,177) GO(T178,178) GO(T179,179) GO(T180,180) \-  GO(T181,181) GO(T182,182) GO(T183,183) GO(T184,184) GO(T185,185) GO(T186,186) GO(T187,187) GO(T188,188) GO(T189,189) \-  GO(T190,190) GO(T191,191) GO(T192,192) GO(T193,193) GO(T194,194) GO(T195,195) GO(T196,196) GO(T197,197) GO(T198,198) \-  GO(T199,199) GO(T200,200) GO(T201,201) GO(T202,202) GO(T203,203) GO(T204,204) GO(T205,205) GO(T206,206) GO(T207,207) \-  GO(T208,208) GO(T209,209) GO(T210,210) GO(T211,211) GO(T212,212) GO(T213,213) GO(T214,214) GO(T215,215) GO(T216,216) \-  GO(T217,217) GO(T218,218) GO(T219,219) GO(T220,220) GO(T221,221) GO(T222,222) GO(T223,223) GO(T224,224) GO(T225,225) \-  GO(T226,226) GO(T227,227) GO(T228,228) GO(T229,229) GO(T230,230) GO(T231,231) GO(T232,232) GO(T233,233) GO(T234,234) \-  GO(T235,235) GO(T236,236) GO(T237,237) GO(T238,238) GO(T239,239) GO(T240,240) GO(T241,241) GO(T242,242) GO(T243,243) \-  GO(T244,244) GO(T245,245) GO(T246,246) GO(T247,247) GO(T248,248) GO(T249,249) GO(T250,250) GO(T251,251) GO(T252,252) \-  GO(T253,253) GO(T254,254) GO(T255,255)--#define GO(Tn,n) \-  newtype Tn = Tn Tn deriving Typeable; \-  instance B Tn where { \-    reflectByte _ = n \-  };-BYTES(GO)-#undef GO--impossible :: a-impossible = error "Data.Reflection.reifyByte: impossible"--reifyByte :: Word8 -> (forall s. B s => Proxy s -> r) -> r-reifyByte w k = case w of {-#define GO(Tn,n) n -> k (Proxy :: Proxy Tn);-BYTES(GO)-#undef GO-_ -> impossible-}--newtype W b0 b1 b2 b3 = W (W b0 b1 b2 b3) deriving Typeable-newtype Stable w0 w1 a = Stable (Stable w0 w1 a) deriving Typeable--stable :: p b0 -> p b1 -> p b2 -> p b3 -> p b4 -> p b5 -> p b6 -> p b7-       -> Proxy (Stable (W b0 b1 b2 b3) (W b4 b5 b6 b7) a)-stable _ _ _ _ _ _ _ _ = Proxy-{-# INLINE stable #-}--stablePtrToIntPtr :: StablePtr a -> IntPtr-stablePtrToIntPtr = ptrToIntPtr . castStablePtrToPtr-{-# INLINE stablePtrToIntPtr #-}--intPtrToStablePtr :: IntPtr -> StablePtr a-intPtrToStablePtr = castPtrToStablePtr . intPtrToPtr-{-# INLINE intPtrToStablePtr #-}--byte0 :: p (Stable (W b0 b1 b2 b3) w1 a) -> Proxy b0-byte0 _ = Proxy--byte1 :: p (Stable (W b0 b1 b2 b3) w1 a) -> Proxy b1-byte1 _ = Proxy--byte2 :: p (Stable (W b0 b1 b2 b3) w1 a) -> Proxy b2-byte2 _ = Proxy--byte3 :: p (Stable (W b0 b1 b2 b3) w1 a) -> Proxy b3-byte3 _ = Proxy--byte4 :: p (Stable w0 (W b4 b5 b6 b7) a) -> Proxy b4-byte4 _ = Proxy--byte5 :: p (Stable w0 (W b4 b5 b6 b7) a) -> Proxy b5-byte5 _ = Proxy--byte6 :: p (Stable w0 (W b4 b5 b6 b7) a) -> Proxy b6-byte6 _ = Proxy--byte7 :: p (Stable w0 (W b4 b5 b6 b7) a) -> Proxy b7-byte7 _ = Proxy--argument :: (p s -> r) -> Proxy s-argument _ = Proxy--instance (B b0, B b1, B b2, B b3, B b4, B b5, B b6, B b7, w0 ~ W b0 b1 b2 b3, w1 ~ W b4 b5 b6 b7)-    => Reifies (Stable w0 w1 a) a where-  reflect = r where-      r = unsafePerformIO $ const <$> deRefStablePtr p <* freeStablePtr p-      s = argument r-      p = intPtrToStablePtr $-        reflectByte (byte0 s) .|.-        (reflectByte (byte1 s) `shiftL` 8) .|.-        (reflectByte (byte2 s) `shiftL` 16) .|.-        (reflectByte (byte3 s) `shiftL` 24) .|.-        (reflectByte (byte4 s) `shiftL` 32) .|.-        (reflectByte (byte5 s) `shiftL` 40) .|.-        (reflectByte (byte6 s) `shiftL` 48) .|.-        (reflectByte (byte7 s) `shiftL` 56)-  {-# NOINLINE reflect #-}---- This had to be moved to the top level, due to an apparent bug in--- the ghc inliner introduced in ghc 7.0.x-reflectBefore :: (Proxy s -> b) -> proxy s -> b-reflectBefore f = const $! f Proxy-{-# NOINLINE reflectBefore #-}---- | Reify a value at the type level in a 'Typeable'-compatible fashion, to be recovered with 'reflect'.-reifyTypeable :: Typeable a => a -> (forall s. (Typeable s, Reifies s a) => Proxy s -> r) -> r-reifyTypeable a k = unsafeDupablePerformIO $ do-  p <- newStablePtr a-  let n = stablePtrToIntPtr p-  reifyByte (fromIntegral n) (\s0 ->-    reifyByte (fromIntegral (n `shiftR` 8)) (\s1 ->-      reifyByte (fromIntegral (n `shiftR` 16)) (\s2 ->-        reifyByte (fromIntegral (n `shiftR` 24)) (\s3 ->-          reifyByte (fromIntegral (n `shiftR` 32)) (\s4 ->-            reifyByte (fromIntegral (n `shiftR` 40)) (\s5 ->-              reifyByte (fromIntegral (n `shiftR` 48)) (\s6 ->-                reifyByte (fromIntegral (n `shiftR` 56)) (\s7 ->-                  reflectBefore (fmap return k) $-                    stable s0 s1 s2 s3 s4 s5 s6 s7))))))))
src/Control/Lens/Plated.hs view
@@ -441,7 +441,7 @@ -- @ -- 'cosmosOn' :: 'Plated' a => 'Fold' s a -> 'Fold' s a -- @-cosmosOn :: (Applicative f, Contravariant f, Plated a) => LensLike' f a a -> LensLike' f a a+cosmosOn :: (Applicative f, Contravariant f, Plated a) => LensLike' f s a -> LensLike' f s a cosmosOn d = cosmosOnOf d plate {-# INLINE cosmosOn #-} 
src/Control/Lens/Wrapped.hs view
@@ -243,8 +243,8 @@   {-# INLINE _Wrapped' #-} #endif -instance (t ~ ArrowMonad m' a', ArrowApply m, ArrowApply m') => Rewrapped (ArrowMonad m a) t-instance ArrowApply m => Wrapped (ArrowMonad m a) where+instance (t ~ ArrowMonad m' a', ArrowApply m) => Rewrapped (ArrowMonad m a) t+instance Wrapped (ArrowMonad m a) where   type Unwrapped (ArrowMonad m a) = m () a   _Wrapped' = iso getArrowMonad ArrowMonad   {-# INLINE _Wrapped' #-}
src/Data/List/Lens.hs view
@@ -17,6 +17,81 @@ -- -- Traversals for manipulating parts of a list. --+-- Additional optics for manipulating lists are present more+-- generically in this package.+--+-- The 'Control.Lens.At.Ixed' class allows traversing the element at a+-- specific list index.+--+-- >>> [0..10] ^? ix 4+-- Just 4+--+-- >>> [0..5] & ix 4 .~ 2+-- [0,1,2,3,2,5]+--+-- >>> [0..10] ^? ix 14+-- Nothing+--+-- >>> [0..5] & ix 14 .~ 2+-- [0,1,2,3,4,5]+--+-- The 'Control.Lens.Cons.Cons' and 'Control.Lens.Empty.AsEmpty'+-- classes provide 'Control.Lens.Prism.Prism's for list constructors.+--+-- >>> [1..10] ^? _Cons+-- Just (1,[2,3,4,5,6,7,8,9,10])+--+-- >>> [] ^? _Cons+-- Nothing+--+-- >>> [] ^? _Empty+-- Just ()+--+-- >>> _Cons # (1, _Empty # ()) :: [Int]+-- [1]+--+-- Additionally, 'Control.Lens.Cons.Snoc' provides a+-- 'Control.Lens.Prism.Prism' for accessing the end of a list. Note+-- that this 'Control.Lens.Prism.Prism' always will need to traverse+-- the whole list.+--+-- >>> [1..5] ^? _Snoc+-- Just ([1,2,3,4],5)+--+-- >>> _Snoc # ([1,2],5)+-- [1,2,5]+--+-- An instance of 'Control.Lens.Plated.Plated' allows for finding+-- locations in the list where a traversal matches.+--+-- >>> [Nothing, Just 7, Just 3, Nothing] & deep (ix 0 . _Just) +~ 10+-- [Nothing,Just 17,Just 3,Nothing]+--+-- An instance of 'Control.Lens.Iso.Reversing' provides an+-- 'Control.Lens.Iso.Iso' between a list and its reverse.+--+-- >>> "live" & reversed %~ ('d':)+-- "lived"+--+-- Finally, it's possible to traverse, fold over, and map over+-- index-value pairs thanks to instances of+-- 'Control.Lens.Indexed.TraversableWithIndex',+-- 'Control.Lens.Indexed.FoldableWithIndex', and+-- 'Control.Lens.Indexed.FunctorWithIndex'.+--+-- >>> imap (,) "Hello"+-- [(0,'H'),(1,'e'),(2,'l'),(3,'l'),(4,'o')]+--+-- >>> ifoldMap replicate "Hello"+-- "ellllloooo"+--+-- >>> itraverse_ (curry print) "Hello"+-- (0,'H')+-- (1,'e')+-- (2,'l')+-- (3,'l')+-- (4,'o')+-- ---------------------------------------------------------------------------- module Data.List.Lens   ( prefixed
src/Generics/Deriving/Lens.hs view
@@ -4,6 +4,10 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE UndecidableInstances #-} +#if __GLASGOW_HASKELL__ >= 711+{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}+#endif+ #ifndef MIN_VERSION_base #define MIN_VERSION_base(x,y,z) 1 #endif