{-# LANGUAGE CPP #-}
{-# LANGUAGE DerivingVia #-}
module Data.Functor.Invariant.Internative (
Inalt(..)
, Inplus(..)
, Internative
, swervedN
, swervedNMap
, swervedN1
, swervedN1Map
) where
import Control.Applicative
import Control.Applicative.Backwards (Backwards(..))
import Control.Arrow (ArrowPlus)
import Control.Monad
import Control.Monad.Trans.Identity (IdentityT(..))
import Data.Functor.Alt
import Data.Functor.Contravariant
import Data.Functor.Contravariant.Conclude
import Data.Functor.Contravariant.Decide
import Data.Functor.Contravariant.Divise
import Data.Functor.Contravariant.Divisible
import Data.Functor.Invariant
import Data.Functor.Invariant.Inplicative
import Data.Functor.Plus
import Data.Functor.Product (Product(..))
import Data.Functor.Reverse (Reverse(..))
import Data.Hashable (Hashable)
import Data.Kind
import Data.List.NonEmpty (NonEmpty)
import Data.SOP hiding (hmap)
import Data.Sequence (Seq)
import Data.StateVar (SettableStateVar)
import Data.Void
import qualified Data.HashMap.Lazy as HM
import qualified Data.IntMap as IM
import qualified Data.IntMap.NonEmpty as NEIM
import qualified Data.Map as M
import qualified Data.Map.NonEmpty as NEM
import qualified Data.Monoid as Monoid
import qualified Data.Semigroup as Semigroup
import qualified Data.Sequence.NonEmpty as NESeq
import qualified GHC.Generics as Generics
class Invariant f => Inalt f where
swerve
:: (b -> a)
-> (c -> a)
-> (a -> Either b c)
-> f b
-> f c
-> f a
swerve b -> a
f c -> a
g a -> Either b c
h f b
x f c
y = forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either b -> a
f c -> a
g) a -> Either b c
h (forall (f :: * -> *) a b. Inalt f => f a -> f b -> f (Either a b)
swerved f b
x f c
y)
swerved
:: f a
-> f b
-> f (Either a b)
swerved = forall (f :: * -> *) b a c.
Inalt f =>
(b -> a) -> (c -> a) -> (a -> Either b c) -> f b -> f c -> f a
swerve forall a b. a -> Either a b
Left forall a b. b -> Either a b
Right forall a. a -> a
id
{-# MINIMAL swerve | swerved #-}
class Inalt f => Inplus f where
reject :: (a -> Void) -> f a
class (Inplus f, Inplicative f) => Internative f
instance Alt f => Inalt (WrappedFunctor f) where
swerved :: forall a b.
WrappedFunctor f a
-> WrappedFunctor f b -> WrappedFunctor f (Either a b)
swerved (WrapFunctor f a
x) (WrapFunctor f b
y) = forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor forall a b. (a -> b) -> a -> b
$
(forall a b. a -> Either a b
Left forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f a
x) forall (f :: * -> *) a. Alt f => f a -> f a -> f a
<!> (forall a b. b -> Either a b
Right forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f b
y)
instance Plus f => Inplus (WrappedFunctor f) where
reject :: forall a. (a -> Void) -> WrappedFunctor f a
reject a -> Void
_ = forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor forall (f :: * -> *) a. Plus f => f a
zero
instance (Alternative f, Plus f, Apply f) => Internative (WrappedFunctor f)
instance Decide f => Inalt (WrappedContravariant f) where
swerve :: forall b a c.
(b -> a)
-> (c -> a)
-> (a -> Either b c)
-> WrappedContravariant f b
-> WrappedContravariant f c
-> WrappedContravariant f a
swerve b -> a
_ c -> a
_ a -> Either b c
h (WrapContravariant f b
x) (WrapContravariant f c
y) = forall {k} (f :: k -> *) (a :: k). f a -> WrappedContravariant f a
WrapContravariant (forall (f :: * -> *) a b c.
Decide f =>
(a -> Either b c) -> f b -> f c -> f a
decide a -> Either b c
h f b
x f c
y)
instance Conclude f => Inplus (WrappedContravariant f) where
reject :: forall a. (a -> Void) -> WrappedContravariant f a
reject a -> Void
f = forall {k} (f :: k -> *) (a :: k). f a -> WrappedContravariant f a
WrapContravariant (forall (f :: * -> *) a. Conclude f => (a -> Void) -> f a
conclude a -> Void
f)
instance (Conclude f, Divisible f, Divise f) => Internative (WrappedContravariant f)
instance Decide f => Inalt (WrappedDivisible f) where
swerve :: forall b a c.
(b -> a)
-> (c -> a)
-> (a -> Either b c)
-> WrappedDivisible f b
-> WrappedDivisible f c
-> WrappedDivisible f a
swerve b -> a
_ c -> a
_ a -> Either b c
h (WrapDivisible f b
x) (WrapDivisible f c
y) = forall {k} (f :: k -> *) (a :: k). f a -> WrappedDivisible f a
WrapDivisible (forall (f :: * -> *) a b c.
Decide f =>
(a -> Either b c) -> f b -> f c -> f a
decide a -> Either b c
h f b
x f c
y)
instance Conclude f => Inplus (WrappedDivisible f) where
reject :: forall a. (a -> Void) -> WrappedDivisible f a
reject a -> Void
f = forall {k} (f :: k -> *) (a :: k). f a -> WrappedDivisible f a
WrapDivisible (forall (f :: * -> *) a. Conclude f => (a -> Void) -> f a
conclude a -> Void
f)
instance (Conclude f, Divisible f, Divise f) => Internative (WrappedDivisible f)
instance (Decidable f, Invariant f) => Inalt (WrappedDivisibleOnly f) where
swerve :: forall b a c.
(b -> a)
-> (c -> a)
-> (a -> Either b c)
-> WrappedDivisibleOnly f b
-> WrappedDivisibleOnly f c
-> WrappedDivisibleOnly f a
swerve b -> a
_ c -> a
_ a -> Either b c
h (WrapDivisibleOnly f b
x) (WrapDivisibleOnly f c
y) = forall {k} (f :: k -> *) (a :: k). f a -> WrappedDivisibleOnly f a
WrapDivisibleOnly (forall (f :: * -> *) a b c.
Decidable f =>
(a -> Either b c) -> f b -> f c -> f a
choose a -> Either b c
h f b
x f c
y)
instance (Decidable f, Invariant f) => Inplus (WrappedDivisibleOnly f) where
reject :: forall a. (a -> Void) -> WrappedDivisibleOnly f a
reject a -> Void
f = forall {k} (f :: k -> *) (a :: k). f a -> WrappedDivisibleOnly f a
WrapDivisibleOnly (forall (f :: * -> *) a. Decidable f => (a -> Void) -> f a
lose a -> Void
f)
instance (Decidable f, Invariant f) => Internative (WrappedDivisibleOnly f)
deriving via WrappedFunctor (Proxy :: Type -> Type) instance Inalt Proxy
deriving via WrappedFunctor (Proxy :: Type -> Type) instance Inplus Proxy
deriving via WrappedFunctor (Proxy :: Type -> Type) instance Internative Proxy
deriving via WrappedFunctor [] instance Inalt []
deriving via WrappedFunctor [] instance Inplus []
deriving via WrappedFunctor [] instance Internative []
deriving via WrappedFunctor Maybe instance Inalt Maybe
deriving via WrappedFunctor Maybe instance Inplus Maybe
deriving via WrappedFunctor Maybe instance Internative Maybe
deriving via WrappedFunctor (Either e) instance Inalt (Either e)
deriving via WrappedFunctor IO instance Inalt IO
deriving via WrappedFunctor IO instance Inplus IO
deriving via WrappedFunctor IO instance Internative IO
deriving via WrappedFunctor (Generics.U1 :: Type -> Type) instance Inalt Generics.U1
deriving via WrappedFunctor (Generics.U1 :: Type -> Type) instance Inplus Generics.U1
deriving via WrappedFunctor (Generics.U1 :: Type -> Type) instance Internative Generics.U1
instance Inalt f => Inalt (Generics.M1 i t f) where
swerve :: forall b a c.
(b -> a)
-> (c -> a)
-> (a -> Either b c)
-> M1 i t f b
-> M1 i t f c
-> M1 i t f a
swerve b -> a
f c -> a
g a -> Either b c
h (Generics.M1 f b
x) (Generics.M1 f c
y) = forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
Generics.M1 (forall (f :: * -> *) b a c.
Inalt f =>
(b -> a) -> (c -> a) -> (a -> Either b c) -> f b -> f c -> f a
swerve b -> a
f c -> a
g a -> Either b c
h f b
x f c
y)
instance Inplus f => Inplus (Generics.M1 i t f) where
reject :: forall a. (a -> Void) -> M1 i t f a
reject = forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
Generics.M1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Inplus f => (a -> Void) -> f a
reject
instance Internative f => Internative (Generics.M1 i t f)
instance (Inalt f, Inalt g) => Inalt (f Generics.:*: g) where
swerve :: forall b a c.
(b -> a)
-> (c -> a)
-> (a -> Either b c)
-> (:*:) f g b
-> (:*:) f g c
-> (:*:) f g a
swerve b -> a
f c -> a
g a -> Either b c
h (f b
x1 Generics.:*: g b
y1) (f c
x2 Generics.:*: g c
y2) =
forall (f :: * -> *) b a c.
Inalt f =>
(b -> a) -> (c -> a) -> (a -> Either b c) -> f b -> f c -> f a
swerve b -> a
f c -> a
g a -> Either b c
h f b
x1 f c
x2 forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
Generics.:*: forall (f :: * -> *) b a c.
Inalt f =>
(b -> a) -> (c -> a) -> (a -> Either b c) -> f b -> f c -> f a
swerve b -> a
f c -> a
g a -> Either b c
h g b
y1 g c
y2
instance (Inplus f, Inplus g) => Inplus (f Generics.:*: g) where
reject :: forall a. (a -> Void) -> (:*:) f g a
reject a -> Void
f = forall (f :: * -> *) a. Inplus f => (a -> Void) -> f a
reject a -> Void
f forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
Generics.:*: forall (f :: * -> *) a. Inplus f => (a -> Void) -> f a
reject a -> Void
f
instance (Internative f, Internative g) => Internative (f Generics.:*: g)
instance (Inalt f, Inalt g) => Inalt (Product f g) where
swerve :: forall b a c.
(b -> a)
-> (c -> a)
-> (a -> Either b c)
-> Product f g b
-> Product f g c
-> Product f g a
swerve b -> a
f c -> a
g a -> Either b c
h (Pair f b
x1 g b
y1) (Pair f c
x2 g c
y2) =
forall (f :: * -> *) b a c.
Inalt f =>
(b -> a) -> (c -> a) -> (a -> Either b c) -> f b -> f c -> f a
swerve b -> a
f c -> a
g a -> Either b c
h f b
x1 f c
x2 forall {k} (f :: k -> *) (g :: k -> *) (a :: k).
f a -> g a -> Product f g a
`Pair` forall (f :: * -> *) b a c.
Inalt f =>
(b -> a) -> (c -> a) -> (a -> Either b c) -> f b -> f c -> f a
swerve b -> a
f c -> a
g a -> Either b c
h g b
y1 g c
y2
instance (Inplus f, Inplus g) => Inplus (Product f g) where
reject :: forall a. (a -> Void) -> Product f g a
reject a -> Void
f = forall (f :: * -> *) a. Inplus f => (a -> Void) -> f a
reject a -> Void
f forall {k} (f :: k -> *) (g :: k -> *) (a :: k).
f a -> g a -> Product f g a
`Pair` forall (f :: * -> *) a. Inplus f => (a -> Void) -> f a
reject a -> Void
f
instance (Internative f, Internative g) => Internative (Product f g)
instance Inalt f => Inalt (Generics.Rec1 f) where
swerve :: forall b a c.
(b -> a)
-> (c -> a)
-> (a -> Either b c)
-> Rec1 f b
-> Rec1 f c
-> Rec1 f a
swerve b -> a
f c -> a
g a -> Either b c
h (Generics.Rec1 f b
x) (Generics.Rec1 f c
y) = forall k (f :: k -> *) (p :: k). f p -> Rec1 f p
Generics.Rec1 (forall (f :: * -> *) b a c.
Inalt f =>
(b -> a) -> (c -> a) -> (a -> Either b c) -> f b -> f c -> f a
swerve b -> a
f c -> a
g a -> Either b c
h f b
x f c
y)
instance Inplus f => Inplus (Generics.Rec1 f) where
reject :: forall a. (a -> Void) -> Rec1 f a
reject = forall k (f :: k -> *) (p :: k). f p -> Rec1 f p
Generics.Rec1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Inplus f => (a -> Void) -> f a
reject
instance Internative f => Internative (Generics.Rec1 f)
instance Inalt f => Inalt (IdentityT f) where
swerve :: forall b a c.
(b -> a)
-> (c -> a)
-> (a -> Either b c)
-> IdentityT f b
-> IdentityT f c
-> IdentityT f a
swerve b -> a
f c -> a
g a -> Either b c
h (IdentityT f b
x) (IdentityT f c
y) = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (forall (f :: * -> *) b a c.
Inalt f =>
(b -> a) -> (c -> a) -> (a -> Either b c) -> f b -> f c -> f a
swerve b -> a
f c -> a
g a -> Either b c
h f b
x f c
y)
instance Inplus f => Inplus (IdentityT f) where
reject :: forall a. (a -> Void) -> IdentityT f a
reject = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Inplus f => (a -> Void) -> f a
reject
instance Internative f => Internative (IdentityT f) where
instance Inalt f => Inalt (Reverse f) where
swerve :: forall b a c.
(b -> a)
-> (c -> a)
-> (a -> Either b c)
-> Reverse f b
-> Reverse f c
-> Reverse f a
swerve b -> a
f c -> a
g a -> Either b c
h (Reverse f b
x) (Reverse f c
y) = forall {k} (f :: k -> *) (a :: k). f a -> Reverse f a
Reverse (forall (f :: * -> *) b a c.
Inalt f =>
(b -> a) -> (c -> a) -> (a -> Either b c) -> f b -> f c -> f a
swerve b -> a
f c -> a
g a -> Either b c
h f b
x f c
y)
instance Inplus f => Inplus (Reverse f) where
reject :: forall a. (a -> Void) -> Reverse f a
reject = forall {k} (f :: k -> *) (a :: k). f a -> Reverse f a
Reverse forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Inplus f => (a -> Void) -> f a
reject
instance Internative f => Internative (Reverse f) where
instance Inalt f => Inalt (Backwards f) where
swerve :: forall b a c.
(b -> a)
-> (c -> a)
-> (a -> Either b c)
-> Backwards f b
-> Backwards f c
-> Backwards f a
swerve b -> a
f c -> a
g a -> Either b c
h (Backwards f b
x) (Backwards f c
y) = forall {k} (f :: k -> *) (a :: k). f a -> Backwards f a
Backwards (forall (f :: * -> *) b a c.
Inalt f =>
(b -> a) -> (c -> a) -> (a -> Either b c) -> f b -> f c -> f a
swerve b -> a
f c -> a
g a -> Either b c
h f b
x f c
y)
instance Inplus f => Inplus (Backwards f) where
reject :: forall a. (a -> Void) -> Backwards f a
reject = forall {k} (f :: k -> *) (a :: k). f a -> Backwards f a
Backwards forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Inplus f => (a -> Void) -> f a
reject
instance Internative f => Internative (Backwards f) where
deriving via WrappedFunctor Semigroup.First instance Inalt Semigroup.First
deriving via WrappedFunctor Semigroup.Last instance Inalt Semigroup.Last
#if !MIN_VERSION_base(4,16,0)
deriving via WrappedFunctor Semigroup.Option instance Inalt Semigroup.Option
deriving via WrappedFunctor Semigroup.Option instance Inplus Semigroup.Option
deriving via WrappedFunctor Semigroup.Option instance Internative Semigroup.Option
#endif
deriving via WrappedFunctor Monoid.First instance Inalt Monoid.First
deriving via WrappedFunctor Monoid.First instance Inplus Monoid.First
deriving via WrappedFunctor Monoid.First instance Internative Monoid.First
deriving via WrappedFunctor Monoid.Last instance Inalt Monoid.Last
deriving via WrappedFunctor Monoid.Last instance Inplus Monoid.Last
deriving via WrappedFunctor Monoid.Last instance Internative Monoid.Last
deriving via WrappedFunctor NonEmpty instance Inalt NonEmpty
deriving via WrappedFunctor Seq instance Inalt Seq
deriving via WrappedFunctor Seq instance Inplus Seq
deriving via WrappedFunctor Seq instance Internative Seq
deriving via WrappedFunctor NESeq.NESeq instance Inalt NESeq.NESeq
deriving via WrappedFunctor (WrappedArrow a b) instance ArrowPlus a => Inalt (WrappedArrow a b)
deriving via WrappedFunctor (WrappedArrow a b) instance ArrowPlus a => Inplus (WrappedArrow a b)
deriving via WrappedFunctor (WrappedArrow a b) instance ArrowPlus a => Internative (WrappedArrow a b)
deriving via WrappedFunctor (Generics.V1 :: Type -> Type) instance Inalt Generics.V1
deriving via WrappedFunctor IM.IntMap instance Inalt IM.IntMap
deriving via WrappedFunctor NEIM.NEIntMap instance Inalt NEIM.NEIntMap
deriving via WrappedFunctor (M.Map k) instance Ord k => Inalt (M.Map k)
deriving via WrappedFunctor (NEM.NEMap k) instance Ord k => Inalt (NEM.NEMap k)
#if MIN_VERSION_base(4,16,0)
deriving via WrappedFunctor (HM.HashMap k) instance Hashable k => Inalt (HM.HashMap k)
#else
deriving via WrappedFunctor (HM.HashMap k) instance (Hashable k, Eq k) => Inalt (HM.HashMap k)
#endif
deriving via WrappedFunctor (WrappedMonad m) instance MonadPlus m => Inalt (WrappedMonad m)
deriving via WrappedFunctor (WrappedMonad m) instance MonadPlus m => Inplus (WrappedMonad m)
deriving via WrappedFunctor (WrappedMonad m) instance MonadPlus m => Internative (WrappedMonad m)
deriving via WrappedDivisible SettableStateVar instance Inalt SettableStateVar
deriving via WrappedDivisible SettableStateVar instance Inplus SettableStateVar
deriving via WrappedDivisible SettableStateVar instance Internative SettableStateVar
deriving via WrappedDivisible Predicate instance Inalt Predicate
deriving via WrappedDivisible Predicate instance Inplus Predicate
deriving via WrappedDivisible Predicate instance Internative Predicate
deriving via WrappedDivisible Comparison instance Inalt Comparison
deriving via WrappedDivisible Comparison instance Inplus Comparison
deriving via WrappedDivisible Comparison instance Internative Comparison
deriving via WrappedDivisible Equivalence instance Inalt Equivalence
deriving via WrappedDivisible Equivalence instance Inplus Equivalence
deriving via WrappedDivisible Equivalence instance Internative Equivalence
deriving via WrappedDivisible (Op r) instance Inalt (Op r)
deriving via WrappedDivisible (Op r) instance Inplus (Op r)
deriving via WrappedDivisible (Op r) instance Monoid r => Internative (Op r)
swervedN
:: Inplus f
=> NP f as
-> f (NS I as)
swervedN :: forall (f :: * -> *) (as :: [*]).
Inplus f =>
NP f as -> f (NS I as)
swervedN = \case
NP f as
Nil -> forall (f :: * -> *) a. Inplus f => (a -> Void) -> f a
reject forall a b. (a -> b) -> a -> b
$ \case {}
f x
x :* NP f xs
xs -> forall (f :: * -> *) b a c.
Inalt f =>
(b -> a) -> (c -> a) -> (a -> Either b c) -> f b -> f c -> f a
swerve
(forall {k} (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> I a
I)
forall {k} (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S
(\case Z (I x
y) -> forall a b. a -> Either a b
Left x
y; S NS I xs
ys -> forall a b. b -> Either a b
Right NS I xs
ys)
f x
x
(forall (f :: * -> *) (as :: [*]).
Inplus f =>
NP f as -> f (NS I as)
swervedN NP f xs
xs)
swervedNMap
:: Inplus f
=> (NS I as -> b)
-> (b -> NS I as)
-> NP f as
-> f b
swervedNMap :: forall (f :: * -> *) (as :: [*]) b.
Inplus f =>
(NS I as -> b) -> (b -> NS I as) -> NP f as -> f b
swervedNMap NS I as -> b
f b -> NS I as
g = forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap NS I as -> b
f b -> NS I as
g forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) (as :: [*]).
Inplus f =>
NP f as -> f (NS I as)
swervedN
swervedN1
:: Inalt f
=> NP f (a ': as)
-> f (NS I (a ': as))
swervedN1 :: forall (f :: * -> *) a (as :: [*]).
Inalt f =>
NP f (a : as) -> f (NS I (a : as))
swervedN1 (f x
x :* NP f xs
xs) = case NP f xs
xs of
NP f xs
Nil -> forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap (forall {k} (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> I a
I) (\case Z (I x
y) -> x
y; S NS I xs
ys -> case NS I xs
ys of {}) f x
x
f x
_ :* NP f xs
_ -> forall (f :: * -> *) b a c.
Inalt f =>
(b -> a) -> (c -> a) -> (a -> Either b c) -> f b -> f c -> f a
swerve
(forall {k} (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> I a
I)
forall {k} (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S
(\case Z (I x
y) -> forall a b. a -> Either a b
Left x
y; S NS I xs
ys -> forall a b. b -> Either a b
Right NS I xs
ys)
f x
x
(forall (f :: * -> *) a (as :: [*]).
Inalt f =>
NP f (a : as) -> f (NS I (a : as))
swervedN1 NP f xs
xs)
swervedN1Map
:: Inalt f
=> (NS I (a ': as) -> b)
-> (b -> NS I (a ': as))
-> NP f (a ': as)
-> f b
swervedN1Map :: forall (f :: * -> *) a (as :: [*]) b.
Inalt f =>
(NS I (a : as) -> b)
-> (b -> NS I (a : as)) -> NP f (a : as) -> f b
swervedN1Map NS I (a : as) -> b
f b -> NS I (a : as)
g = forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap NS I (a : as) -> b
f b -> NS I (a : as)
g forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a (as :: [*]).
Inalt f =>
NP f (a : as) -> f (NS I (a : as))
swervedN1