control-iso 0.1.0.1 → 0.1.0.2
raw patch · 2 files changed
+49/−3 lines, 2 filesdep ~basedep ~profunctorsPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base, profunctors
API changes (from Hackage documentation)
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.Either.Either () a) (GHC.Base.Maybe a)
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.Either.Either a ()) (GHC.Base.Maybe a)
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.List.NonEmpty.NonEmpty a) (a, [a])
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.Monoid.Dual a) a
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.Monoid.Endo a) (a -> a)
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.Monoid.First a) (GHC.Base.Maybe a)
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.Monoid.Last a) (GHC.Base.Maybe a)
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.Monoid.Product a) a
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.Monoid.Sum a) a
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (GHC.Base.Maybe ()) Control.Isomorphic.IsJust
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (GHC.Base.Maybe ()) Control.Isomorphic.IsNothing
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (GHC.Base.Maybe a) (Data.Either.Either () a)
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (GHC.Base.Maybe a) (Data.Either.Either a ())
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (GHC.Base.Maybe a) (Data.Monoid.First a)
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (GHC.Base.Maybe a) (Data.Monoid.Last a)
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (a -> a) (Data.Monoid.Endo a)
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic (a, [a]) (Data.List.NonEmpty.NonEmpty a)
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic Control.Isomorphic.IsJust (GHC.Base.Maybe ())
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic Control.Isomorphic.IsNothing (GHC.Base.Maybe ())
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic Data.Monoid.All GHC.Types.Bool
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic Data.Monoid.Any GHC.Types.Bool
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic GHC.Types.Bool Data.Monoid.All
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic GHC.Types.Bool Data.Monoid.Any
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic a (Data.Monoid.Dual a)
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic a (Data.Monoid.Product a)
- Control.Isomorphic: instance Control.Isomorphic.Isomorphic a (Data.Monoid.Sum a)
+ Control.Isomorphic: instance (GHC.Base.Functor f, Control.Isomorphic.Isomorphic a b) => Control.Isomorphic.Isomorphic (f a) (f b)
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.Either.Either () a) (GHC.Maybe.Maybe a)
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.Either.Either a ()) (GHC.Maybe.Maybe a)
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.Monoid.First a) (GHC.Maybe.Maybe a)
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.Monoid.Last a) (GHC.Maybe.Maybe a)
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.Semigroup.Internal.Dual a) a
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.Semigroup.Internal.Endo a) (a -> a)
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.Semigroup.Internal.Product a) a
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (Data.Semigroup.Internal.Sum a) a
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (GHC.Base.NonEmpty a) (a, [a])
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (GHC.Maybe.Maybe ()) Control.Isomorphic.IsJust
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (GHC.Maybe.Maybe ()) Control.Isomorphic.IsNothing
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (GHC.Maybe.Maybe a) (Data.Either.Either () a)
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (GHC.Maybe.Maybe a) (Data.Either.Either a ())
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (GHC.Maybe.Maybe a) (Data.Monoid.First a)
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (GHC.Maybe.Maybe a) (Data.Monoid.Last a)
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (a -> a) (Data.Semigroup.Internal.Endo a)
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic (a, [a]) (GHC.Base.NonEmpty a)
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic Control.Isomorphic.IsJust (GHC.Maybe.Maybe ())
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic Control.Isomorphic.IsNothing (GHC.Maybe.Maybe ())
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic Data.Semigroup.Internal.All GHC.Types.Bool
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic Data.Semigroup.Internal.Any GHC.Types.Bool
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic GHC.Types.Bool Data.Semigroup.Internal.All
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic GHC.Types.Bool Data.Semigroup.Internal.Any
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic a (Data.Semigroup.Internal.Dual a)
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic a (Data.Semigroup.Internal.Product a)
+ Control.Isomorphic: instance Control.Isomorphic.Isomorphic a (Data.Semigroup.Internal.Sum a)
+ Control.Isomorphic: instance GHC.Types.Coercible a b => Control.Isomorphic.Isomorphic a b
Files
- control-iso.cabal +3/−3
- src/Control/Isomorphic.hs +46/−0
control-iso.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: control-iso-version: 0.1.0.1+version: 0.1.0.2 synopsis: A typeclass for type isomorphisms description: This is a type class for type isomorphisms, it provides string conversions as well as for newtypes and common types license: BSD3@@ -24,10 +24,10 @@ -- other-modules: -- other-extensions: ghc-options: -Wall- build-depends: base >= 4.9 && <4.12+ build-depends: base >= 4.9 && <4.13 , bytestring >= 0.10.8 && < 0.11 , newtype-generics >= 0.5.1 && < 0.6- , profunctors >= 5.2.1 && < 5.3+ , profunctors >= 5.2.1 && < 5.4 , text >= 1.2.2 && < 1.3 hs-source-dirs: src
src/Control/Isomorphic.hs view
@@ -11,8 +11,10 @@ {-# LANGUAGE TypeFamilyDependencies #-} {-# LANGUAGE UndecidableSuperClasses #-} + module Control.Isomorphic where + import Control.Applicative import Control.Arrow import qualified Control.Monad.ST.Lazy as SL@@ -22,6 +24,7 @@ import qualified Data.ByteString.Char8 as BSC import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Lazy.Char8 as BLC+import Data.Coerce import Data.Fixed import Data.Functor.Compose import Data.Functor.Identity@@ -260,39 +263,73 @@ to' _ = False instance Isomorphic (WrappedMonad m a) (m a) where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic (m a) (WrappedMonad m a) where to' = N.pack+ {-# INLINE to' #-} instance Isomorphic (WrappedArrow a b c) (a b c) where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic (a b c) (WrappedArrow a b c) where to' = N.pack+ {-# INLINE to' #-} instance Isomorphic (ZipList a) [a] where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic [a] (ZipList a) where to' = N.pack+ {-# INLINE to' #-} instance Isomorphic (Kleisli m a b) (a -> m b) where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic (a -> m b) (Kleisli m a b) where to' = N.pack+ {-# INLINE to' #-} instance Isomorphic (ArrowMonad a b) (a () b) where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic (a () b) (ArrowMonad a b) where to' = N.pack+ {-# INLINE to' #-} instance Isomorphic (Fixed a) Integer where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic Integer (Fixed a) where to' = N.pack+ {-# INLINE to' #-} instance Isomorphic (Compose f g a) (f (g a)) where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic (f (g a)) (Compose f g a) where to' = N.pack+ {-# INLINE to' #-} instance Isomorphic (Const a x) a where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic a (Const a x) where to' = N.pack+ {-# INLINE to' #-} instance Isomorphic (Identity a) a where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic a (Identity a) where to' = N.pack+ {-# INLINE to' #-} instance Isomorphic (Dual a) a where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic a (Dual a) where to' = N.pack+ {-# INLINE to' #-} instance Isomorphic (Endo a) (a -> a) where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic (a -> a) (Endo a) where to' = N.pack+ {-# INLINE to' #-} instance Isomorphic All Bool where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic Bool All where to' = N.pack+ {-# INLINE to' #-} instance Isomorphic Any Bool where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic Bool Any where to' = N.pack+ {-# INLINE to' #-} instance Isomorphic (Sum a) a where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic a (Sum a) where to' = N.pack+ {-# INLINE to' #-} instance Isomorphic (Product a) a where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic a (Product a) where to' = N.pack+ {-# INLINE to' #-} instance Isomorphic (First a) (Maybe a) where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic (Maybe a) (First a) where to' = N.pack+ {-# INLINE to' #-} instance Isomorphic (Last a) (Maybe a) where to' = N.unpack+ {-# INLINE to' #-} instance Isomorphic (Maybe a) (Last a) where to' = N.pack+ {-# INLINE to' #-} -- | lift a function to any types to which it is isomorphic as :: (Isomorphic b d, Isomorphic c a) => (a -> b) -> c -> d@@ -309,3 +346,12 @@ -- | A free lens @Iso s t a b@ from the `Isomorphic` instances isoBi :: (Profunctor p, Isomorphic s a, Isomorphic b t, Functor f) => p a (f b) -> p s (f t) isoBi = dimap to (fmap to)+++instance {-# OVERLAPPABLE #-} Coercible a b => Isomorphic a b where to' = coerce+ {-# INLINE to' #-}++instance (Functor f, Isomorphic a b) => Isomorphic (f a) (f b) where to' = fmap to+-- instance (Functor f, Functor g, Isomorphic a b) => Isomorphic (g (f a)) (g (f b)) where to' = (fmap . fmap) to+-- instance (Functor f, Functor g, Functor h, Isomorphic a b) => Isomorphic (h (g (f a))) (h (g (f b))) where to' = (fmap . fmap . fmap) to+-- instance (Functor f, Functor g, Functor h, Functor k, Isomorphic a b) => Isomorphic (k (h (g (f a)))) (k (h (g (f b)))) where to' = (fmap . fmap . fmap . fmap) to