extensible 0.4.10.1 → 0.5
raw patch · 20 files changed
+81/−180 lines, 20 filesdep −semigroupsPVP ok
version bump matches the API change (PVP)
Dependencies removed: semigroups
API changes (from Hackage documentation)
- Data.Extensible.Bits: instance forall k r a (b :: k). Data.Extensible.Bits.FromBits r a => Data.Extensible.Bits.FromBits r (Data.Extensible.Wrapper.Const' a b)
- Data.Extensible.Dictionary: instance forall k a (b :: k). Data.Vector.Unboxed.Base.Unbox a => Data.Vector.Generic.Base.Vector Data.Vector.Unboxed.Base.Vector (Data.Extensible.Wrapper.Const' a b)
- Data.Extensible.Dictionary: instance forall k a (b :: k). Data.Vector.Unboxed.Base.Unbox a => Data.Vector.Generic.Mutable.Base.MVector Data.Vector.Unboxed.Base.MVector (Data.Extensible.Wrapper.Const' a b)
- Data.Extensible.Dictionary: instance forall k a (b :: k). Data.Vector.Unboxed.Base.Unbox a => Data.Vector.Unboxed.Base.Unbox (Data.Extensible.Wrapper.Const' a b)
- Data.Extensible.Wrapper: Const' :: a -> Const' a x
- Data.Extensible.Wrapper: [getConst'] :: Const' a x -> a
- Data.Extensible.Wrapper: instance Data.Extensible.Wrapper.Wrapper (Data.Extensible.Wrapper.Const' a)
- Data.Extensible.Wrapper: instance Data.Foldable.Foldable (Data.Extensible.Wrapper.Const' a)
- Data.Extensible.Wrapper: instance Data.Traversable.Traversable (Data.Extensible.Wrapper.Const' a)
- Data.Extensible.Wrapper: instance GHC.Base.Functor (Data.Extensible.Wrapper.Const' a)
- Data.Extensible.Wrapper: instance forall a k (x :: k). Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Data.Extensible.Wrapper.Const' a x)
- Data.Extensible.Wrapper: instance forall a k (x :: k). Data.Hashable.Class.Hashable a => Data.Hashable.Class.Hashable (Data.Extensible.Wrapper.Const' a x)
- Data.Extensible.Wrapper: instance forall a k (x :: k). GHC.Base.Monoid a => GHC.Base.Monoid (Data.Extensible.Wrapper.Const' a x)
- Data.Extensible.Wrapper: instance forall a k (x :: k). GHC.Base.Semigroup a => GHC.Base.Semigroup (Data.Extensible.Wrapper.Const' a x)
- Data.Extensible.Wrapper: instance forall a k (x :: k). GHC.Classes.Eq a => GHC.Classes.Eq (Data.Extensible.Wrapper.Const' a x)
- Data.Extensible.Wrapper: instance forall a k (x :: k). GHC.Classes.Ord a => GHC.Classes.Ord (Data.Extensible.Wrapper.Const' a x)
- Data.Extensible.Wrapper: instance forall a k (x :: k). GHC.Generics.Generic (Data.Extensible.Wrapper.Const' a x)
- Data.Extensible.Wrapper: instance forall a k (x :: k). GHC.Show.Show a => GHC.Show.Show (Data.Extensible.Wrapper.Const' a x)
- Data.Extensible.Wrapper: instance forall a k (x :: k). Test.QuickCheck.Arbitrary.Arbitrary a => Test.QuickCheck.Arbitrary.Arbitrary (Data.Extensible.Wrapper.Const' a x)
- Data.Extensible.Wrapper: newtype Const' a x
+ Data.Extensible.Bits: instance forall k r a (b :: k). Data.Extensible.Bits.FromBits r a => Data.Extensible.Bits.FromBits r (Data.Functor.Const.Const a b)
+ Data.Extensible.Product: (=<:) :: Wrapper h => Repr h x -> (h :* xs) -> h :* (x : xs)
+ Data.Extensible.Wrapper: instance Data.Extensible.Wrapper.Wrapper (Data.Functor.Const.Const a)
+ Data.Extensible.Wrapper: unwrap :: Wrapper h => h v -> Repr h v
+ Data.Extensible.Wrapper: wrap :: Wrapper h => Repr h v -> h v
- Data.Extensible.Product: infixr 0 <!
+ Data.Extensible.Product: infixr 0 =<:
Files
- .travis.yml +6/−11
- CHANGELOG.md +8/−0
- examples/eff.hs +0/−23
- examples/misc.hs +22/−0
- extensible.cabal +2/−3
- src/Data/Extensible.hs +0/−2
- src/Data/Extensible/Bits.hs +5/−5
- src/Data/Extensible/Class.hs +0/−10
- src/Data/Extensible/Dictionary.hs +0/−59
- src/Data/Extensible/Field.hs +0/−17
- src/Data/Extensible/Inclusion.hs +0/−6
- src/Data/Extensible/Internal.hs +0/−12
- src/Data/Extensible/Label.hs +0/−3
- src/Data/Extensible/Match.hs +0/−1
- src/Data/Extensible/Nullable.hs +0/−1
- src/Data/Extensible/Product.hs +7/−3
- src/Data/Extensible/Sum.hs +0/−3
- src/Data/Extensible/TH.hs +0/−4
- src/Data/Extensible/Tangle.hs +0/−1
- src/Data/Extensible/Wrapper.hs +31/−16
.travis.yml view
@@ -28,18 +28,13 @@ matrix: include:- - compiler: "ghc-7.10.3"- # env: TEST=--disable-tests BENCH=--disable-benchmarks- addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.10.3], sources: [hvr-ghc]}}- - compiler: "ghc-8.0.2"- # env: TEST=--disable-tests BENCH=--disable-benchmarks- addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}}- - compiler: "ghc-8.2.1"- # env: TEST=--disable-tests BENCH=--disable-benchmarks- addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}}- - compiler: "ghc-8.4.1"+ - compiler: "ghc-8.4.4" env: GHCHEAD=true- addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.4.1], sources: [hvr-ghc]}}+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.4.4], sources: [hvr-ghc]}}+ - compiler: "ghc-8.6.3"+ env: GHCHEAD=true+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.6.3], sources: [hvr-ghc]}}+ before_install: - HC=${CC}
CHANGELOG.md view
@@ -1,3 +1,11 @@+0.5+-------------------------------------------------+* GHC older than 8.4 is no longer supported+* Removed `Const'`+* `Data.Extensible.Plain` is no longer exported from `Data.Extensible`+* Added `wrap` and `unwrap` to `Wrapper`+* Added `(=<:)`+ 0.4.10.1 ------------------------------------------------- * Fixed build on GHC 8.6
− examples/eff.hs
@@ -1,23 +0,0 @@-{-# LANGUAGE TypeApplications, OverloadedLabels, PolyKinds, DataKinds, ScopedTypeVariables, Rank2Types #-}-import Data.Extensible--import Prelude hiding (readFile)-import Control.Exception-import Data.ByteString (ByteString)--data FileSystem r where- ReadFile- :: FilePath- -> FileSystem (Either SomeException ByteString)--readFile- :: forall xs- . (Associate "fs" FileSystem xs- , Associate "fs_error" (EitherEff SomeException) xs)- => FilePath- -> Eff xs ByteString-readFile fp = liftEff #fs (ReadFile fp)- >>= either (throwEff #fs_error) pure--foo :: forall xs. Associate "fs" FileSystem xs => Eff xs (Either SomeException ByteString)-foo = castEff (runEitherEff @ "fs_error" (readFile "foo") :: Eff '["fs" >: FileSystem] (Either SomeException ByteString))
+ examples/misc.hs view
@@ -0,0 +1,22 @@+{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, TypeApplications #-}++import Data.Extensible+import Data.Functor.Identity+import Data.Proxy+import GHC.TypeLits+import Data.Extensible.Internal.Rig+import Data.Typeable+import Data.Functor.Product++-- | Collect keys+keys :: forall proxy xs. Forall (KeyIs KnownSymbol) xs => proxy xs -> [String]+keys _ = henumerateFor (Proxy @ (KeyIs KnownSymbol)) (Proxy @ xs)+ ((:) . symbolVal . proxyAssocKey) []++values :: Forall (ValueIs Show) xs => Record xs -> [String]+values = hfoldrWithIndexFor (Proxy @ (ValueIs Show))+ (const $ (:) . show . view _Wrapper) []++values' :: Forall (ValueIs (Product Typeable Show)) xs => Record xs -> [String]+values' = hfoldrWithIndexFor (Proxy @ (ValueIs Show))+ (const $ (:) . show . view _Wrapper) []
extensible.cabal view
@@ -1,5 +1,5 @@ name: extensible-version: 0.4.10.1+version: 0.5 synopsis: Extensible, efficient, optics-friendly data types and effects homepage: https://github.com/fumieval/extensible bug-reports: http://github.com/fumieval/extensible/issues@@ -15,7 +15,7 @@ category: Data, Records, Monads build-type: Simple stability: experimental-Tested-With: GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.1, GHC == 8.4.1+Tested-With: GHC == 8.4.4, GHC == 8.6.3 extra-source-files: examples/*.hs@@ -84,7 +84,6 @@ , profunctors , resourcet , QuickCheck- , semigroups , StateVar , tagged , template-haskell
src/Data/Extensible.hs view
@@ -36,7 +36,6 @@ , module Data.Extensible.Label , module Data.Extensible.Match , module Data.Extensible.Nullable- , module Data.Extensible.Plain , module Data.Extensible.Product , module Data.Extensible.Record , module Data.Extensible.Sum@@ -55,7 +54,6 @@ import Data.Extensible.Label import Data.Extensible.Match import Data.Extensible.Nullable-import Data.Extensible.Plain import Data.Extensible.Product import Data.Extensible.Record import Data.Extensible.Sum
src/Data/Extensible/Bits.hs view
@@ -21,6 +21,7 @@ , BitRecordOf , BitRecord) where +import Control.Applicative import Control.Comonad import Data.Bits import Data.Extensible.Class@@ -28,7 +29,6 @@ import Data.Extensible.Product import Data.Extensible.Internal (getMemberId) import Data.Extensible.Field-import Data.Extensible.Wrapper import Data.Functor.Identity import Data.Hashable import Data.Ix@@ -130,10 +130,10 @@ toBits (a, b) = unsafeShiftL (toBits a) width .|. toBits b where width = fromInteger $ natVal (Proxy :: Proxy (BitWidth b)) -instance FromBits r a => FromBits r (Const' a b) where- type BitWidth (Const' a b) = BitWidth a- fromBits = Const' . fromBits- toBits = toBits . getConst'+instance FromBits r a => FromBits r (Const a b) where+ type BitWidth (Const a b) = BitWidth a+ fromBits = Const . fromBits+ toBits = toBits . getConst instance (Bits r, FromBits r (h (AssocValue x))) => FromBits r (Field h x) where type BitWidth (Field h x) = BitWidth (h (AssocValue x))
src/Data/Extensible/Class.hs view
@@ -1,7 +1,5 @@ {-# LANGUAGE MultiParamTypeClasses, UndecidableInstances, ScopedTypeVariables, TypeFamilies #-}-#if __GLASGOW_HASKELL__ >= 800 {-# LANGUAGE UndecidableSuperClasses #-}-#endif ----------------------------------------------------------------------------- -- | -- Module : Data.Extensible.Class@@ -28,11 +26,7 @@ -- * Member , Member(..) , remember-#if __GLASGOW_HASKELL__ >= 800 , type (∈)-#else- , (∈)()-#endif , FindType -- * Generation , Generate(..)@@ -40,11 +34,7 @@ , ForallF -- * Association , Assoc(..)-#if __GLASGOW_HASKELL__ >= 800 , type (>:)-#else- , (>:)()-#endif , Associate(..) , FindAssoc -- * Sugar
src/Data/Extensible/Dictionary.hs view
@@ -2,10 +2,8 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies, ScopedTypeVariables #-} {-# LANGUAGE UndecidableInstances, MultiParamTypeClasses #-}-#if __GLASGOW_HASKELL__ >= 800 {-# LANGUAGE UndecidableSuperClasses #-} {-# LANGUAGE TypeInType #-}-#endif {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -----------------------------------------------------------------------@@ -20,10 +18,7 @@ -- Also includes orphan instances. ----------------------------------------------------------------------- module Data.Extensible.Dictionary (library, WrapForall, Instance1, And) where-import Control.Applicative import Control.DeepSeq-import Control.Monad.Trans-import Control.Monad.Trans.Cont import qualified Data.Aeson as J import qualified Data.Csv as Csv import qualified Data.ByteString.Char8 as BC@@ -40,12 +35,7 @@ import Data.Functor.Identity import Data.Hashable import qualified Data.HashMap.Strict as HM-import Data.Semigroup import Data.Text.Prettyprint.Doc-import Data.Typeable-#if __GLASGOW_HASKELL__ >= 800-import Data.Kind-#endif import qualified Data.Vector.Generic as G import qualified Data.Vector.Generic.Mutable as M import qualified Data.Vector.Unboxed as U@@ -346,53 +336,4 @@ instance (U.Unbox a) => U.Unbox (Identity a) -newtype instance U.MVector s (Const' a b) = MV_Const (U.MVector s a)-newtype instance U.Vector (Const' a b) = V_Const (U.Vector a)--instance (U.Unbox a) => M.MVector U.MVector (Const' a b) where- {-# INLINE basicLength #-}- {-# INLINE basicUnsafeSlice #-}- {-# INLINE basicOverlaps #-}- {-# INLINE basicUnsafeNew #-}- {-# INLINE basicUnsafeReplicate #-}- {-# INLINE basicUnsafeRead #-}- {-# INLINE basicUnsafeWrite #-}- {-# INLINE basicClear #-}- {-# INLINE basicSet #-}- {-# INLINE basicUnsafeCopy #-}- {-# INLINE basicUnsafeGrow #-}- basicLength (MV_Const v) = M.basicLength v- basicUnsafeSlice i n (MV_Const v) = MV_Const $ M.basicUnsafeSlice i n v- basicOverlaps (MV_Const v1) (MV_Const v2) = M.basicOverlaps v1 v2- basicUnsafeNew n = MV_Const <$> M.basicUnsafeNew n-#if MIN_VERSION_vector(0,11,0)- basicInitialize (MV_Const v) = M.basicInitialize v- {-# INLINE basicInitialize #-} #endif- basicUnsafeReplicate n (Const' x) = MV_Const <$> M.basicUnsafeReplicate n x- basicUnsafeRead (MV_Const v) i = Const' <$> M.basicUnsafeRead v i- basicUnsafeWrite (MV_Const v) i (Const' x) = M.basicUnsafeWrite v i x- basicClear (MV_Const v) = M.basicClear v- basicSet (MV_Const v) (Const' x) = M.basicSet v x- basicUnsafeCopy (MV_Const v1) (MV_Const v2) = M.basicUnsafeCopy v1 v2- basicUnsafeMove (MV_Const v1) (MV_Const v2) = M.basicUnsafeMove v1 v2- basicUnsafeGrow (MV_Const v) n = MV_Const <$> M.basicUnsafeGrow v n--instance (U.Unbox a) => G.Vector U.Vector (Const' a b) where- {-# INLINE basicUnsafeFreeze #-}- {-# INLINE basicUnsafeThaw #-}- {-# INLINE basicLength #-}- {-# INLINE basicUnsafeSlice #-}- {-# INLINE basicUnsafeIndexM #-}- basicUnsafeFreeze (MV_Const v) = V_Const <$> G.basicUnsafeFreeze v- basicUnsafeThaw (V_Const v) = MV_Const <$> G.basicUnsafeThaw v- basicLength (V_Const v) = G.basicLength v- basicUnsafeSlice i n (V_Const v) = V_Const $ G.basicUnsafeSlice i n v- basicUnsafeIndexM (V_Const v) i = Const' <$> G.basicUnsafeIndexM v i- basicUnsafeCopy (MV_Const mv) (V_Const v) = G.basicUnsafeCopy mv v--instance (U.Unbox a) => U.Unbox (Const' a b)-#endif--proxyApp :: Proxy f -> Proxy a -> Proxy (f a)-proxyApp _ _ = Proxy
src/Data/Extensible/Field.hs view
@@ -4,9 +4,7 @@ {-# LANGUAGE ScopedTypeVariables, TypeFamilies #-} {-# LANGUAGE CPP #-} {-# LANGUAGE TemplateHaskell #-}-#if __GLASGOW_HASKELL__ >= 800 {-# LANGUAGE UndecidableSuperClasses, TypeInType #-}-#endif ----------------------------------------------------------------------------- -- | -- Module : Data.Extensible.Field@@ -63,14 +61,11 @@ import Data.Extensible.Product import Data.Extensible.Internal import Data.Extensible.Internal.Rig-#if __GLASGOW_HASKELL__ >= 800 import Data.Kind-#endif import Data.Profunctor.Unsafe import Data.Extensible.Wrapper import Data.Functor.Identity import Data.Hashable-import Data.Semigroup import Data.String import Data.Text.Prettyprint.Doc import Data.Typeable (Typeable)@@ -125,11 +120,7 @@ -- -- @'Field' :: (v -> *) -> Assoc k v -> *@ ---#if __GLASGOW_HASKELL__ >= 800 newtype Field (h :: v -> Type) (kv :: Assoc k v)-#else-newtype Field (h :: v -> *) (kv :: Assoc k v)-#endif = Field { getField :: h (AssocValue kv) } deriving (Typeable, Generic)@@ -283,11 +274,7 @@ -- -- 'FieldOptic's can be generated using 'mkField' defined in the "Data.Extensible.TH" module. ---#if __GLASGOW_HASKELL__ >= 800 type FieldOptic k = forall kind. forall f p t xs (h :: kind -> Type) (v :: kind).-#else-type FieldOptic k = forall f p t xs (h :: kind -> *) (v :: kind).-#endif (Extensible f p t , ExtensibleConstr t (Field h) xs (k ':> v) , Associate k v xs@@ -295,12 +282,8 @@ , Wrapper h) => Optic' p f (t (Field h) xs) (Repr h v) -#if __GLASGOW_HASKELL__ >= 800 -- | The trivial inextensible data type data Inextensible (h :: k -> Type) (xs :: [k])-#else-data Inextensible (h :: k -> *) (xs :: [k])-#endif instance (Functor f, Profunctor p) => Extensible f p Inextensible where pieceAt _ _ = error "Impossible"
src/Data/Extensible/Inclusion.hs view
@@ -2,9 +2,7 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-}-#if __GLASGOW_HASKELL__ >= 800 {-# LANGUAGE UndecidableSuperClasses #-}-#endif ------------------------------------------------------------------------ -- | -- Module : Data.Extensible.Inclusion@@ -16,11 +14,7 @@ ------------------------------------------------------------------------ module Data.Extensible.Inclusion ( -- * Inclusion-#if __GLASGOW_HASKELL__ >= 800 type (⊆)-#else- (⊆)()-#endif , Include , inclusion , shrink
src/Data/Extensible/Internal.hs view
@@ -33,19 +33,11 @@ -- * Member class , Member(..) , remember-#if __GLASGOW_HASKELL__ >= 800 , type (∈)-#else- , (∈)()-#endif , FindType -- * Association , Assoc(..)-#if __GLASGOW_HASKELL__ >= 800 , type (>:)-#else- , (>:)()-#endif , Associate(..) , FindAssoc -- * Sugar@@ -60,10 +52,6 @@ import Control.DeepSeq (NFData) import Data.Type.Equality import Data.Proxy-#if !MIN_VERSION_base(4,8,0)-import Control.Applicative-import Data.Word-#endif import Control.Monad import Unsafe.Coerce import Data.Hashable
src/Data/Extensible/Label.hs view
@@ -12,8 +12,6 @@ ----------------------------------------------------------------------------- module Data.Extensible.Label where -#if __GLASGOW_HASKELL__ >= 800- import Data.Extensible.Class import Data.Extensible.Field import Data.Proxy@@ -46,5 +44,4 @@ fromLabel = itemAssoc (Proxy :: Proxy k) #else fromLabel _ = itemAssoc (Proxy :: Proxy k)-#endif #endif
src/Data/Extensible/Match.hs view
@@ -23,7 +23,6 @@ import Data.Extensible.Wrapper import Data.Typeable (Typeable) import Data.Profunctor.Unsafe-import Data.Semigroup import GHC.Generics (Generic) -- | Retrieve the contents so that they matches and pass both to the given function.
src/Data/Extensible/Nullable.hs view
@@ -27,7 +27,6 @@ import Data.Extensible.Wrapper import qualified Data.Extensible.Struct as S import Data.Profunctor.Unsafe-import Data.Semigroup import GHC.Generics (Generic) import Language.Haskell.TH.Lift import Language.Haskell.TH (appE, conE)
src/Data/Extensible/Product.hs view
@@ -17,6 +17,7 @@ , nil , (<:) , (<!)+ , (=<:) , hlength , type (++) , happend@@ -61,11 +62,9 @@ , hrepeatFor) where import Data.Extensible.Internal+import Data.Extensible.Internal.Rig (review) import Data.Extensible.Struct import Data.Extensible.Sum-#if !MIN_VERSION_base(4,8,0)-import Control.Applicative-#endif import Data.Extensible.Class import qualified Data.Extensible.HList as HList import Data.Extensible.Wrapper@@ -76,6 +75,11 @@ (<:) x = fromHList . HList.HCons x . toHList {-# INLINE (<:) #-} infixr 0 <:++(=<:) :: Wrapper h => Repr h x -> h :* xs -> h :* (x ': xs)+(=<:) = (<:) . review _Wrapper+{-# INLINE (=<:) #-}+infixr 0 =<: -- | Strict version of ('<:'). (<!) :: h x -> h :* xs -> h :* (x ': xs)
src/Data/Extensible/Sum.hs view
@@ -24,9 +24,6 @@ ) where import Data.Extensible.Internal-#if !MIN_VERSION_base(4,8,0)-import Control.Applicative-#endif import Data.Typeable import Data.Extensible.Class import Data.Profunctor
src/Data/Extensible/TH.hs view
@@ -25,10 +25,6 @@ import Data.Char import Control.Monad -#if !MIN_VERSION_base(4,8,0)-import Data.Foldable (foldMap)-#endif- -- | Generate fields using 'itemAssoc'. -- @'mkField' "foo Bar"@ defines: --
src/Data/Extensible/Tangle.hs view
@@ -27,7 +27,6 @@ import Data.Extensible.Internal.Rig import Data.Extensible.Nullable import Data.Extensible.Wrapper-import Data.Semigroup -- | @'TangleT' h xs m@ is the monad of computations that may depend on the elements in 'xs'. newtype TangleT h xs m a = TangleT
src/Data/Extensible/Wrapper.hs view
@@ -13,12 +13,12 @@ module Data.Extensible.Wrapper ( Wrapper(..) , _WrapperAs- , Const'(..) , Comp(..) , comp , Prod(..) ) where +import Control.Applicative import Control.DeepSeq import Data.Typeable (Typeable) import Data.Proxy (Proxy(..))@@ -26,7 +26,6 @@ import Data.Functor.Identity (Identity(..)) import Data.Extensible.Internal.Rig import Data.Hashable-import Data.Semigroup import Data.Text.Prettyprint.Doc import GHC.Generics (Generic) import Language.Haskell.TH.Lift@@ -45,7 +44,19 @@ -- @_Wrapper :: Iso' (h v) (Repr h v)@ -- _Wrapper :: (Functor f, Profunctor p) => Optic' p f (h v) (Repr h v)+ _Wrapper = dimap unwrap (fmap wrap)+ {-# INLINE _Wrapper #-} + wrap :: Repr h v -> h v+ wrap = review _Wrapper+ {-# INLINE wrap #-}++ unwrap :: h v -> Repr h v+ unwrap = view _Wrapper+ {-# INLINE unwrap #-}++ {-# MINIMAL wrap, unwrap | _Wrapper #-}+ -- | Restricted version of '_Wrapper'. -- It is useful for eliminating ambiguousness. _WrapperAs :: (Functor f, Profunctor p, Wrapper h) => proxy v -> Optic' p f (h v) (Repr h v)@@ -54,8 +65,10 @@ instance Wrapper Identity where type Repr Identity a = a- _Wrapper = dimap runIdentity (fmap Identity)- {-# INLINE _Wrapper #-}+ unwrap = runIdentity+ {-# INLINE unwrap #-}+ wrap = Identity+ {-# INLINE wrap #-} instance Wrapper Maybe where type Repr Maybe a = Maybe a@@ -90,19 +103,19 @@ _Wrapper = withIso _Wrapper $ \f g -> dimap (fmap f .# getComp) (fmap (comp g)) {-# INLINE _Wrapper #-} --- | Poly-kinded Const-newtype Const' a x = Const' { getConst' :: a }- deriving (Show, Eq, Ord, Typeable, Generic, NFData, Semigroup, Monoid, Functor, Foldable, Traversable, Arbitrary, Hashable)--instance Wrapper (Const' a) where- type Repr (Const' a) b = a- _Wrapper = dimap getConst' (fmap Const')- {-# INLINE _Wrapper #-}+instance Wrapper (Const a) where+ type Repr (Const a) b = a+ wrap = Const+ {-# INLINE wrap #-}+ unwrap = getConst+ {-# INLINE unwrap #-} instance Wrapper Proxy where type Repr Proxy x = ()- _Wrapper = dimap (const ()) (fmap (const Proxy))- {-# INLINE _Wrapper #-}+ wrap _ = Proxy+ {-# INLINE wrap #-}+ unwrap _ = ()+ {-# INLINE unwrap #-} -- | Poly-kinded product data Prod f g a = Prod (f a) (g a)@@ -113,8 +126,10 @@ instance (Wrapper f, Wrapper g) => Wrapper (Prod f g) where type Repr (Prod f g) a = (Repr f a, Repr g a)- _Wrapper = dimap (\(Prod f g) -> (view _Wrapper f, view _Wrapper g))- $ fmap (\(a, b) -> review _Wrapper a `Prod` review _Wrapper b)+ unwrap (Prod f g) = (unwrap f, unwrap g)+ {-# INLINE unwrap #-}+ wrap (f, g) = wrap f `Prod` wrap g+ {-# INLINE wrap #-} instance (Semigroup (f a), Semigroup (g a)) => Semigroup (Prod f g a) where Prod a b <> Prod c d = Prod (a <> c) (b <> d)