module UVMHS.Core.Classes.Functors where
import UVMHS.Core.Init
import UVMHS.Core.Classes.Morphism
import qualified Prelude as HS
infixr 0 ^$, ^^$
infixl 7 ^∘, ^^∘
infixr 0 *$
infixl 1 ≫=, ≫
infixl 6 ⧆
infixl 7 *∘
newtype NoCostID (a ∷ ★) = NoCostID a
instance Functor NoCostID where
map ∷ ∀ a b. (a → b) → NoCostID a → NoCostID b
map :: forall a b. (a -> b) -> NoCostID a -> NoCostID b
map = forall a b. Coercible a b => a -> b
forall a b. Coercible a b => a -> b
coerce @((a → b) → a → b) (a -> b) -> a -> b
forall a. a -> a
id
instance Return NoCostID where
return ∷ ∀ a. a → NoCostID a
return :: forall a. a -> NoCostID a
return = forall a b. Coercible a b => a -> b
forall a b. Coercible a b => a -> b
coerce @a
instance Bind NoCostID where
(≫=) ∷ ∀ a b. NoCostID a → (a → NoCostID b) → NoCostID b
≫= :: forall a b. NoCostID a -> (a -> NoCostID b) -> NoCostID b
(≫=) = forall a b. Coercible a b => a -> b
forall a b. Coercible a b => a -> b
coerce @(a → (a → b) → b) a -> (a -> b) -> b
forall a b. a -> (a -> b) -> b
appto
instance Monad NoCostID
class FunctorM (t ∷ ★ → ★) where
mapM ∷ ∀ m a b. (Monad m) ⇒ (a → m b) → t a → m (t b)
default mapM ∷ (OFunctorM t,Monad m) ⇒ (a → m b) → t a → m (t b)
mapM a -> m b
f = (a -> m (𝑂 b)) -> t a -> m (t b)
forall (t :: * -> *) (m :: * -> *) a b.
(OFunctorM t, Monad m) =>
(a -> m (𝑂 b)) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(a -> m (𝑂 b)) -> t a -> m (t b)
omapM ((a -> m (𝑂 b)) -> t a -> m (t b))
-> (a -> m (𝑂 b)) -> t a -> m (t b)
forall a b. (a -> b) -> a -> b
$ (b -> 𝑂 b) -> m b -> m (𝑂 b)
forall a b. (a -> b) -> m a -> m b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map b -> 𝑂 b
forall a. a -> 𝑂 a
Some (m b -> m (𝑂 b)) -> (a -> m b) -> a -> m (𝑂 b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ a -> m b
f
class OFunctorM (t ∷ ★ → ★) where
omapM ∷ ∀ m a b. (Monad m) ⇒ (a → m (𝑂 b)) → t a → m (t b)
class KFunctorM (k ∷ ★) (t ∷ ★ → ★) | t → k where
kmapM ∷ ∀ m a b. (Monad m) ⇒ (k → a → m b) → t a → m (t b)
kmapAtM ∷ ∀ m a. (Monad m) ⇒ k → (a → m a) → t a → m (t a)
default kmapM ∷ (OKFunctorM k t,Monad m) ⇒ (k → a → m b) → t a → m (t b)
kmapM k -> a -> m b
f = (k -> a -> m (𝑂 b)) -> t a -> m (t b)
forall k (t :: * -> *) (m :: * -> *) a b.
(OKFunctorM k t, Monad m) =>
(k -> a -> m (𝑂 b)) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(k -> a -> m (𝑂 b)) -> t a -> m (t b)
okmapM ((k -> a -> m (𝑂 b)) -> t a -> m (t b))
-> (k -> a -> m (𝑂 b)) -> t a -> m (t b)
forall a b. (a -> b) -> a -> b
$ (b -> 𝑂 b) -> m b -> m (𝑂 b)
forall a b. (a -> b) -> m a -> m b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map b -> 𝑂 b
forall a. a -> 𝑂 a
Some (m b -> m (𝑂 b)) -> (k -> a -> m b) -> k -> a -> m (𝑂 b)
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
∘∘ k -> a -> m b
f
default kmapAtM ∷ (OKFunctorM k t,Monad m) ⇒ k → (a → m a) → t a → m (t a)
kmapAtM k
k a -> m a
f = k -> (𝑂 a -> m (𝑂 a)) -> t a -> m (t a)
forall k (t :: * -> *) (m :: * -> *) a.
(OKFunctorM k t, Monad m) =>
k -> (𝑂 a -> m (𝑂 a)) -> t a -> m (t a)
forall (m :: * -> *) a.
Monad m =>
k -> (𝑂 a -> m (𝑂 a)) -> t a -> m (t a)
okmapAtM k
k ((𝑂 a -> m (𝑂 a)) -> t a -> m (t a))
-> (𝑂 a -> m (𝑂 a)) -> t a -> m (t a)
forall a b. (a -> b) -> a -> b
$ \case {𝑂 a
None→𝑂 a -> m (𝑂 a)
forall a. a -> m a
forall (m :: * -> *) a. Return m => a -> m a
return 𝑂 a
forall a. 𝑂 a
None;Some a
x → a -> 𝑂 a
forall a. a -> 𝑂 a
Some (a -> 𝑂 a) -> m a -> m (𝑂 a)
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ a -> m a
f a
x}
class OKFunctorM (k ∷ ★) (t ∷ ★ → ★) | t → k where
okmapM ∷ ∀ m a b. (Monad m) ⇒ (k → a → m (𝑂 b)) → t a → m (t b)
okmapAtM ∷ ∀ m a. (Monad m) ⇒ k → (𝑂 a → m (𝑂 a)) → t a → m (t a)
class BiFunctorM (t ∷ ★ → ★) where
bimapM ∷ ∀ m a b c. (Monad m) ⇒ (a → m c) → (b → m c) → (a → b → m c) → t a → t b → m (t c)
default bimapM ∷ (OBiFunctorM t,Monad m) ⇒ (a → m c) → (b → m c) → (a → b → m c) → t a → t b → m (t c)
bimapM a -> m c
f₁ b -> m c
f₂ a -> b -> m c
f₃ = (a -> m (𝑂 c))
-> (b -> m (𝑂 c)) -> (a -> b -> m (𝑂 c)) -> t a -> t b -> m (t c)
forall (t :: * -> *) (m :: * -> *) a b c.
(OBiFunctorM t, Monad m) =>
(a -> m (𝑂 c))
-> (b -> m (𝑂 c)) -> (a -> b -> m (𝑂 c)) -> t a -> t b -> m (t c)
forall (m :: * -> *) a b c.
Monad m =>
(a -> m (𝑂 c))
-> (b -> m (𝑂 c)) -> (a -> b -> m (𝑂 c)) -> t a -> t b -> m (t c)
obimapM ((c -> 𝑂 c) -> m c -> m (𝑂 c)
forall a b. (a -> b) -> m a -> m b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map c -> 𝑂 c
forall a. a -> 𝑂 a
Some (m c -> m (𝑂 c)) -> (a -> m c) -> a -> m (𝑂 c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ a -> m c
f₁) ((c -> 𝑂 c) -> m c -> m (𝑂 c)
forall a b. (a -> b) -> m a -> m b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map c -> 𝑂 c
forall a. a -> 𝑂 a
Some (m c -> m (𝑂 c)) -> (b -> m c) -> b -> m (𝑂 c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ b -> m c
f₂) ((a -> b -> m (𝑂 c)) -> t a -> t b -> m (t c))
-> (a -> b -> m (𝑂 c)) -> t a -> t b -> m (t c)
forall a b. (a -> b) -> a -> b
$ (c -> 𝑂 c) -> m c -> m (𝑂 c)
forall a b. (a -> b) -> m a -> m b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map c -> 𝑂 c
forall a. a -> 𝑂 a
Some (m c -> m (𝑂 c)) -> (a -> b -> m c) -> a -> b -> m (𝑂 c)
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
∘∘ a -> b -> m c
f₃
class OBiFunctorM (t ∷ ★ → ★) where
obimapM ∷ ∀ m a b c. (Monad m) ⇒ (a → m (𝑂 c)) → (b → m (𝑂 c)) → (a → b → m (𝑂 c)) → t a → t b → m (t c)
class KBiFunctorM (k ∷ ★) (t ∷ ★ → ★) | t → k where
kbimapM ∷ ∀ m a b c. (Monad m) ⇒ (k → a → m c) → (k → b → m c) → (k → a → b → m c) → t a → t b → m (t c)
default kbimapM ∷ (OKBiFunctorM k t,Monad m) ⇒ (k → a → m c) → (k → b → m c) → (k → a → b → m c) → t a → t b → m (t c)
kbimapM k -> a -> m c
f₁ k -> b -> m c
f₂ k -> a -> b -> m c
f₃ = (k -> a -> m (𝑂 c))
-> (k -> b -> m (𝑂 c))
-> (k -> a -> b -> m (𝑂 c))
-> t a
-> t b
-> m (t c)
forall k (t :: * -> *) (m :: * -> *) a b c.
(OKBiFunctorM k t, Monad m) =>
(k -> a -> m (𝑂 c))
-> (k -> b -> m (𝑂 c))
-> (k -> a -> b -> m (𝑂 c))
-> t a
-> t b
-> m (t c)
forall (m :: * -> *) a b c.
Monad m =>
(k -> a -> m (𝑂 c))
-> (k -> b -> m (𝑂 c))
-> (k -> a -> b -> m (𝑂 c))
-> t a
-> t b
-> m (t c)
okbimapM ((c -> 𝑂 c) -> m c -> m (𝑂 c)
forall a b. (a -> b) -> m a -> m b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map c -> 𝑂 c
forall a. a -> 𝑂 a
Some (m c -> m (𝑂 c)) -> (k -> a -> m c) -> k -> a -> m (𝑂 c)
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
∘∘ k -> a -> m c
f₁) ((c -> 𝑂 c) -> m c -> m (𝑂 c)
forall a b. (a -> b) -> m a -> m b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map c -> 𝑂 c
forall a. a -> 𝑂 a
Some (m c -> m (𝑂 c)) -> (k -> b -> m c) -> k -> b -> m (𝑂 c)
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
∘∘ k -> b -> m c
f₂) ((k -> a -> b -> m (𝑂 c)) -> t a -> t b -> m (t c))
-> (k -> a -> b -> m (𝑂 c)) -> t a -> t b -> m (t c)
forall a b. (a -> b) -> a -> b
$ (c -> 𝑂 c) -> m c -> m (𝑂 c)
forall a b. (a -> b) -> m a -> m b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map c -> 𝑂 c
forall a. a -> 𝑂 a
Some (m c -> m (𝑂 c)) -> (k -> a -> b -> m c) -> k -> a -> b -> m (𝑂 c)
forall d e a b c.
(d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e
∘∘∘ k -> a -> b -> m c
f₃
class OKBiFunctorM (k ∷ ★) (t ∷ ★ → ★) | t → k where
okbimapM ∷ ∀ m a b c. (Monad m) ⇒ (k → a → m (𝑂 c)) → (k → b → m (𝑂 c)) → (k → a → b → m (𝑂 c)) → t a → t b → m (t c)
class Functor (t ∷ ★ → ★) where
map ∷ (a → b) → t a → t b
default map ∷ ∀ a b. (FunctorM t) ⇒ (a → b) → t a → t b
map a -> b
f = (t a -> NoCostID (t b)) -> t a -> t b
forall a b. Coercible a b => a -> b
coerce ((t a -> NoCostID (t b)) -> t a -> t b)
-> (t a -> NoCostID (t b)) -> t a -> t b
forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) (m :: * -> *) a b.
(FunctorM t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM @t @NoCostID @a @b ((a -> NoCostID b) -> t a -> NoCostID (t b))
-> (a -> NoCostID b) -> t a -> NoCostID (t b)
forall a b. (a -> b) -> a -> b
$ (a -> b) -> a -> NoCostID b
forall a b. Coercible a b => a -> b
coerce a -> b
f
class OFunctor (t ∷ ★ → ★) where
omap ∷ (a → 𝑂 b) → t a → t b
default omap ∷ ∀ a b. (OFunctorM t) ⇒ (a → 𝑂 b) → t a → t b
omap a -> 𝑂 b
f = (t a -> NoCostID (t b)) -> t a -> t b
forall a b. Coercible a b => a -> b
coerce ((t a -> NoCostID (t b)) -> t a -> t b)
-> (t a -> NoCostID (t b)) -> t a -> t b
forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) (m :: * -> *) a b.
(OFunctorM t, Monad m) =>
(a -> m (𝑂 b)) -> t a -> m (t b)
omapM @t @NoCostID @a @b ((a -> NoCostID (𝑂 b)) -> t a -> NoCostID (t b))
-> (a -> NoCostID (𝑂 b)) -> t a -> NoCostID (t b)
forall a b. (a -> b) -> a -> b
$ (a -> 𝑂 b) -> a -> NoCostID (𝑂 b)
forall a b. Coercible a b => a -> b
coerce a -> 𝑂 b
f
class KFunctor (k ∷ ★) (t ∷ ★ → ★) | t → k where
kmap ∷ (k → a → b) → t a → t b
kmapAt ∷ k → (a → a) → t a → t a
default kmap ∷ ∀ a b. (KFunctorM k t) ⇒ (k → a → b) → t a → t b
kmap k -> a -> b
f = (t a -> NoCostID (t b)) -> t a -> t b
forall a b. Coercible a b => a -> b
coerce ((t a -> NoCostID (t b)) -> t a -> t b)
-> (t a -> NoCostID (t b)) -> t a -> t b
forall a b. (a -> b) -> a -> b
$ forall k (t :: * -> *) (m :: * -> *) a b.
(KFunctorM k t, Monad m) =>
(k -> a -> m b) -> t a -> m (t b)
kmapM @k @t @NoCostID @a @b ((k -> a -> NoCostID b) -> t a -> NoCostID (t b))
-> (k -> a -> NoCostID b) -> t a -> NoCostID (t b)
forall a b. (a -> b) -> a -> b
$ (k -> a -> b) -> k -> a -> NoCostID b
forall a b. Coercible a b => a -> b
coerce k -> a -> b
f
default kmapAt ∷ ∀ a. (KFunctorM k t) ⇒ k → (a → a) → t a → t a
kmapAt k
k a -> a
f = (t a -> NoCostID (t a)) -> t a -> t a
forall a b. Coercible a b => a -> b
coerce ((t a -> NoCostID (t a)) -> t a -> t a)
-> (t a -> NoCostID (t a)) -> t a -> t a
forall a b. (a -> b) -> a -> b
$ forall k (t :: * -> *) (m :: * -> *) a.
(KFunctorM k t, Monad m) =>
k -> (a -> m a) -> t a -> m (t a)
kmapAtM @k @t @NoCostID @a k
k ((a -> NoCostID a) -> t a -> NoCostID (t a))
-> (a -> NoCostID a) -> t a -> NoCostID (t a)
forall a b. (a -> b) -> a -> b
$ (a -> a) -> a -> NoCostID a
forall a b. Coercible a b => a -> b
coerce a -> a
f
class OKFunctor (k ∷ ★) (t ∷ ★ → ★) | t → k where
okmap ∷ (k → a → 𝑂 b) → t a → t b
okmapAt ∷ k → (𝑂 a → 𝑂 a) → t a → t a
default okmap ∷ ∀ a b. (OKFunctorM k t) ⇒ (k → a → 𝑂 b) → t a → t b
okmap k -> a -> 𝑂 b
f = (t a -> NoCostID (t b)) -> t a -> t b
forall a b. Coercible a b => a -> b
coerce ((t a -> NoCostID (t b)) -> t a -> t b)
-> (t a -> NoCostID (t b)) -> t a -> t b
forall a b. (a -> b) -> a -> b
$ forall k (t :: * -> *) (m :: * -> *) a b.
(OKFunctorM k t, Monad m) =>
(k -> a -> m (𝑂 b)) -> t a -> m (t b)
okmapM @k @t @NoCostID @a @b ((k -> a -> NoCostID (𝑂 b)) -> t a -> NoCostID (t b))
-> (k -> a -> NoCostID (𝑂 b)) -> t a -> NoCostID (t b)
forall a b. (a -> b) -> a -> b
$ (k -> a -> 𝑂 b) -> k -> a -> NoCostID (𝑂 b)
forall a b. Coercible a b => a -> b
coerce k -> a -> 𝑂 b
f
default okmapAt ∷ ∀ a. (OKFunctorM k t) ⇒ k → (𝑂 a → 𝑂 a) → t a → t a
okmapAt k
k 𝑂 a -> 𝑂 a
f = (t a -> NoCostID (t a)) -> t a -> t a
forall a b. Coercible a b => a -> b
coerce ((t a -> NoCostID (t a)) -> t a -> t a)
-> (t a -> NoCostID (t a)) -> t a -> t a
forall a b. (a -> b) -> a -> b
$ forall k (t :: * -> *) (m :: * -> *) a.
(OKFunctorM k t, Monad m) =>
k -> (𝑂 a -> m (𝑂 a)) -> t a -> m (t a)
okmapAtM @k @t @NoCostID @a k
k ((𝑂 a -> NoCostID (𝑂 a)) -> t a -> NoCostID (t a))
-> (𝑂 a -> NoCostID (𝑂 a)) -> t a -> NoCostID (t a)
forall a b. (a -> b) -> a -> b
$ (𝑂 a -> 𝑂 a) -> 𝑂 a -> NoCostID (𝑂 a)
forall a b. Coercible a b => a -> b
coerce 𝑂 a -> 𝑂 a
f
class BiFunctor (t ∷ ★ → ★) where
bimap ∷ (a → c) → (b → c) → (a → b → c) → t a → t b → t c
default bimap ∷ ∀ a b c. (BiFunctorM t) ⇒ (a → c) → (b → c) → (a → b → c) → t a → t b → t c
bimap a -> c
f₁ b -> c
f₂ a -> b -> c
f₃ = (t a -> t b -> NoCostID (t c)) -> t a -> t b -> t c
forall a b. Coercible a b => a -> b
coerce ((t a -> t b -> NoCostID (t c)) -> t a -> t b -> t c)
-> (t a -> t b -> NoCostID (t c)) -> t a -> t b -> t c
forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) (m :: * -> *) a b c.
(BiFunctorM t, Monad m) =>
(a -> m c)
-> (b -> m c) -> (a -> b -> m c) -> t a -> t b -> m (t c)
bimapM @t @NoCostID @a @b @c ((a -> c) -> a -> NoCostID c
forall a b. Coercible a b => a -> b
coerce a -> c
f₁) ((b -> c) -> b -> NoCostID c
forall a b. Coercible a b => a -> b
coerce b -> c
f₂) ((a -> b -> NoCostID c) -> t a -> t b -> NoCostID (t c))
-> (a -> b -> NoCostID c) -> t a -> t b -> NoCostID (t c)
forall a b. (a -> b) -> a -> b
$ (a -> b -> c) -> a -> b -> NoCostID c
forall a b. Coercible a b => a -> b
coerce a -> b -> c
f₃
class OBiFunctor (t ∷ ★ → ★) where
obimap ∷ (a → 𝑂 c) → (b → 𝑂 c) → (a → b → 𝑂 c) → t a → t b → t c
default obimap ∷ ∀ a b c. (OBiFunctorM t) ⇒ (a → 𝑂 c) → (b → 𝑂 c) → (a → b → 𝑂 c) → t a → t b → t c
obimap a -> 𝑂 c
f₁ b -> 𝑂 c
f₂ a -> b -> 𝑂 c
f₃ = (t a -> t b -> NoCostID (t c)) -> t a -> t b -> t c
forall a b. Coercible a b => a -> b
coerce ((t a -> t b -> NoCostID (t c)) -> t a -> t b -> t c)
-> (t a -> t b -> NoCostID (t c)) -> t a -> t b -> t c
forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) (m :: * -> *) a b c.
(OBiFunctorM t, Monad m) =>
(a -> m (𝑂 c))
-> (b -> m (𝑂 c)) -> (a -> b -> m (𝑂 c)) -> t a -> t b -> m (t c)
obimapM @t @NoCostID @a @b @c ((a -> 𝑂 c) -> a -> NoCostID (𝑂 c)
forall a b. Coercible a b => a -> b
coerce a -> 𝑂 c
f₁) ((b -> 𝑂 c) -> b -> NoCostID (𝑂 c)
forall a b. Coercible a b => a -> b
coerce b -> 𝑂 c
f₂) ((a -> b -> NoCostID (𝑂 c)) -> t a -> t b -> NoCostID (t c))
-> (a -> b -> NoCostID (𝑂 c)) -> t a -> t b -> NoCostID (t c)
forall a b. (a -> b) -> a -> b
$ (a -> b -> 𝑂 c) -> a -> b -> NoCostID (𝑂 c)
forall a b. Coercible a b => a -> b
coerce a -> b -> 𝑂 c
f₃
class KBiFunctor (k ∷ ★) (t ∷ ★ → ★) where
kbimap ∷ (k → a → c) → (k → b → c) → (k → a → b → c) → t a → t b → t c
default kbimap ∷ ∀ a b c. (KBiFunctorM k t) ⇒ (k → a → c) → (k → b → c) → (k → a → b → c) → t a → t b → t c
kbimap k -> a -> c
f₁ k -> b -> c
f₂ k -> a -> b -> c
f₃ = (t a -> t b -> NoCostID (t c)) -> t a -> t b -> t c
forall a b. Coercible a b => a -> b
coerce ((t a -> t b -> NoCostID (t c)) -> t a -> t b -> t c)
-> (t a -> t b -> NoCostID (t c)) -> t a -> t b -> t c
forall a b. (a -> b) -> a -> b
$ forall k (t :: * -> *) (m :: * -> *) a b c.
(KBiFunctorM k t, Monad m) =>
(k -> a -> m c)
-> (k -> b -> m c) -> (k -> a -> b -> m c) -> t a -> t b -> m (t c)
kbimapM @k @t @NoCostID @a @b @c ((k -> a -> c) -> k -> a -> NoCostID c
forall a b. Coercible a b => a -> b
coerce k -> a -> c
f₁) ((k -> b -> c) -> k -> b -> NoCostID c
forall a b. Coercible a b => a -> b
coerce k -> b -> c
f₂) ((k -> a -> b -> NoCostID c) -> t a -> t b -> NoCostID (t c))
-> (k -> a -> b -> NoCostID c) -> t a -> t b -> NoCostID (t c)
forall a b. (a -> b) -> a -> b
$ (k -> a -> b -> c) -> k -> a -> b -> NoCostID c
forall a b. Coercible a b => a -> b
coerce k -> a -> b -> c
f₃
class OKBiFunctor (k ∷ ★) (t ∷ ★ → ★) where
okbimap ∷ (k → a → 𝑂 c) → (k → b → 𝑂 c) → (k → a → b → 𝑂 c) → t a → t b → t c
default okbimap ∷ ∀ a b c. (OKBiFunctorM k t) ⇒ (k → a → 𝑂 c) → (k → b → 𝑂 c) → (k → a → b → 𝑂 c) → t a → t b → t c
okbimap k -> a -> 𝑂 c
f₁ k -> b -> 𝑂 c
f₂ k -> a -> b -> 𝑂 c
f₃ = (t a -> t b -> NoCostID (t c)) -> t a -> t b -> t c
forall a b. Coercible a b => a -> b
coerce ((t a -> t b -> NoCostID (t c)) -> t a -> t b -> t c)
-> (t a -> t b -> NoCostID (t c)) -> t a -> t b -> t c
forall a b. (a -> b) -> a -> b
$ forall k (t :: * -> *) (m :: * -> *) a b c.
(OKBiFunctorM k t, Monad m) =>
(k -> a -> m (𝑂 c))
-> (k -> b -> m (𝑂 c))
-> (k -> a -> b -> m (𝑂 c))
-> t a
-> t b
-> m (t c)
okbimapM @k @t @NoCostID @a @b @c ((k -> a -> 𝑂 c) -> k -> a -> NoCostID (𝑂 c)
forall a b. Coercible a b => a -> b
coerce k -> a -> 𝑂 c
f₁) ((k -> b -> 𝑂 c) -> k -> b -> NoCostID (𝑂 c)
forall a b. Coercible a b => a -> b
coerce k -> b -> 𝑂 c
f₂) ((k -> a -> b -> NoCostID (𝑂 c)) -> t a -> t b -> NoCostID (t c))
-> (k -> a -> b -> NoCostID (𝑂 c)) -> t a -> t b -> NoCostID (t c)
forall a b. (a -> b) -> a -> b
$ (k -> a -> b -> 𝑂 c) -> k -> a -> b -> NoCostID (𝑂 c)
forall a b. Coercible a b => a -> b
coerce k -> a -> b -> 𝑂 c
f₃
mapMOn ∷ (FunctorM t,Monad m) ⇒ t a → (a → m b) → m (t b)
mapMOn :: forall (t :: * -> *) (m :: * -> *) a b.
(FunctorM t, Monad m) =>
t a -> (a -> m b) -> m (t b)
mapMOn = ((a -> m b) -> t a -> m (t b)) -> t a -> (a -> m b) -> m (t b)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (a -> m b) -> t a -> m (t b)
forall (t :: * -> *) (m :: * -> *) a b.
(FunctorM t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> t a -> m (t b)
mapM
exchange ∷ (FunctorM t,Monad m) ⇒ t (m a) → m (t a)
exchange :: forall (t :: * -> *) (m :: * -> *) a.
(FunctorM t, Monad m) =>
t (m a) -> m (t a)
exchange = (m a -> m a) -> t (m a) -> m (t a)
forall (t :: * -> *) (m :: * -> *) a b.
(FunctorM t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> t a -> m (t b)
mapM m a -> m a
forall a. a -> a
id
omapMOn ∷ (OFunctorM t,Monad m) ⇒ t a → (a → m (𝑂 b)) → m (t b)
omapMOn :: forall (t :: * -> *) (m :: * -> *) a b.
(OFunctorM t, Monad m) =>
t a -> (a -> m (𝑂 b)) -> m (t b)
omapMOn = ((a -> m (𝑂 b)) -> t a -> m (t b))
-> t a -> (a -> m (𝑂 b)) -> m (t b)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (a -> m (𝑂 b)) -> t a -> m (t b)
forall (t :: * -> *) (m :: * -> *) a b.
(OFunctorM t, Monad m) =>
(a -> m (𝑂 b)) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(a -> m (𝑂 b)) -> t a -> m (t b)
omapM
kmapMOn ∷ (KFunctorM k t,Monad m) ⇒ t a → (k → a → m b) → m (t b)
kmapMOn :: forall k (t :: * -> *) (m :: * -> *) a b.
(KFunctorM k t, Monad m) =>
t a -> (k -> a -> m b) -> m (t b)
kmapMOn = ((k -> a -> m b) -> t a -> m (t b))
-> t a -> (k -> a -> m b) -> m (t b)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (k -> a -> m b) -> t a -> m (t b)
forall k (t :: * -> *) (m :: * -> *) a b.
(KFunctorM k t, Monad m) =>
(k -> a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(k -> a -> m b) -> t a -> m (t b)
kmapM
kmapAtMOn ∷ (KFunctorM k t,Monad m) ⇒ k → t a → (a → m a) → m (t a)
kmapAtMOn :: forall k (t :: * -> *) (m :: * -> *) a.
(KFunctorM k t, Monad m) =>
k -> t a -> (a -> m a) -> m (t a)
kmapAtMOn = ((a -> m a) -> t a -> m (t a)) -> t a -> (a -> m a) -> m (t a)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (((a -> m a) -> t a -> m (t a)) -> t a -> (a -> m a) -> m (t a))
-> (k -> (a -> m a) -> t a -> m (t a))
-> k
-> t a
-> (a -> m a)
-> m (t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ k -> (a -> m a) -> t a -> m (t a)
forall k (t :: * -> *) (m :: * -> *) a.
(KFunctorM k t, Monad m) =>
k -> (a -> m a) -> t a -> m (t a)
forall (m :: * -> *) a.
Monad m =>
k -> (a -> m a) -> t a -> m (t a)
kmapAtM
okmapMOn ∷ (OKFunctorM k t,Monad m) ⇒ t a → (k → a → m (𝑂 b)) → m (t b)
okmapMOn :: forall k (t :: * -> *) (m :: * -> *) a b.
(OKFunctorM k t, Monad m) =>
t a -> (k -> a -> m (𝑂 b)) -> m (t b)
okmapMOn = ((k -> a -> m (𝑂 b)) -> t a -> m (t b))
-> t a -> (k -> a -> m (𝑂 b)) -> m (t b)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (k -> a -> m (𝑂 b)) -> t a -> m (t b)
forall k (t :: * -> *) (m :: * -> *) a b.
(OKFunctorM k t, Monad m) =>
(k -> a -> m (𝑂 b)) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(k -> a -> m (𝑂 b)) -> t a -> m (t b)
okmapM
okmapAtMOn ∷ (OKFunctorM k t,Monad m) ⇒ k → t a → (𝑂 a → m (𝑂 a)) → m (t a)
okmapAtMOn :: forall k (t :: * -> *) (m :: * -> *) a.
(OKFunctorM k t, Monad m) =>
k -> t a -> (𝑂 a -> m (𝑂 a)) -> m (t a)
okmapAtMOn = ((𝑂 a -> m (𝑂 a)) -> t a -> m (t a))
-> t a -> (𝑂 a -> m (𝑂 a)) -> m (t a)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (((𝑂 a -> m (𝑂 a)) -> t a -> m (t a))
-> t a -> (𝑂 a -> m (𝑂 a)) -> m (t a))
-> (k -> (𝑂 a -> m (𝑂 a)) -> t a -> m (t a))
-> k
-> t a
-> (𝑂 a -> m (𝑂 a))
-> m (t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ k -> (𝑂 a -> m (𝑂 a)) -> t a -> m (t a)
forall k (t :: * -> *) (m :: * -> *) a.
(OKFunctorM k t, Monad m) =>
k -> (𝑂 a -> m (𝑂 a)) -> t a -> m (t a)
forall (m :: * -> *) a.
Monad m =>
k -> (𝑂 a -> m (𝑂 a)) -> t a -> m (t a)
okmapAtM
bimapMOn ∷ (BiFunctorM t,Monad m) ⇒ t a → t b → (a → m c) → (b → m c) → (a → b → m c) → m (t c)
bimapMOn :: forall (t :: * -> *) (m :: * -> *) a b c.
(BiFunctorM t, Monad m) =>
t a
-> t b -> (a -> m c) -> (b -> m c) -> (a -> b -> m c) -> m (t c)
bimapMOn = \ t a
xM t b
yM a -> m c
f₁ b -> m c
f₂ a -> b -> m c
f₃ → (a -> m c)
-> (b -> m c) -> (a -> b -> m c) -> t a -> t b -> m (t c)
forall (t :: * -> *) (m :: * -> *) a b c.
(BiFunctorM t, Monad m) =>
(a -> m c)
-> (b -> m c) -> (a -> b -> m c) -> t a -> t b -> m (t c)
forall (m :: * -> *) a b c.
Monad m =>
(a -> m c)
-> (b -> m c) -> (a -> b -> m c) -> t a -> t b -> m (t c)
bimapM a -> m c
f₁ b -> m c
f₂ a -> b -> m c
f₃ t a
xM t b
yM
obimapMOn ∷ (OBiFunctorM t,Monad m) ⇒ t a → t b → (a → m (𝑂 c)) → (b → m (𝑂 c)) → (a → b → m (𝑂 c)) → m (t c)
obimapMOn :: forall (t :: * -> *) (m :: * -> *) a b c.
(OBiFunctorM t, Monad m) =>
t a
-> t b
-> (a -> m (𝑂 c))
-> (b -> m (𝑂 c))
-> (a -> b -> m (𝑂 c))
-> m (t c)
obimapMOn = \ t a
xM t b
yM a -> m (𝑂 c)
f₁ b -> m (𝑂 c)
f₂ a -> b -> m (𝑂 c)
f₃ → (a -> m (𝑂 c))
-> (b -> m (𝑂 c)) -> (a -> b -> m (𝑂 c)) -> t a -> t b -> m (t c)
forall (t :: * -> *) (m :: * -> *) a b c.
(OBiFunctorM t, Monad m) =>
(a -> m (𝑂 c))
-> (b -> m (𝑂 c)) -> (a -> b -> m (𝑂 c)) -> t a -> t b -> m (t c)
forall (m :: * -> *) a b c.
Monad m =>
(a -> m (𝑂 c))
-> (b -> m (𝑂 c)) -> (a -> b -> m (𝑂 c)) -> t a -> t b -> m (t c)
obimapM a -> m (𝑂 c)
f₁ b -> m (𝑂 c)
f₂ a -> b -> m (𝑂 c)
f₃ t a
xM t b
yM
kbimapMOn ∷ (KBiFunctorM k t,Monad m) ⇒ t a → t b → (k → a → m c) → (k → b → m c) → (k → a → b → m c) → m (t c)
kbimapMOn :: forall k (t :: * -> *) (m :: * -> *) a b c.
(KBiFunctorM k t, Monad m) =>
t a
-> t b
-> (k -> a -> m c)
-> (k -> b -> m c)
-> (k -> a -> b -> m c)
-> m (t c)
kbimapMOn = \ t a
xM t b
yM k -> a -> m c
f₁ k -> b -> m c
f₂ k -> a -> b -> m c
f₃ → (k -> a -> m c)
-> (k -> b -> m c) -> (k -> a -> b -> m c) -> t a -> t b -> m (t c)
forall k (t :: * -> *) (m :: * -> *) a b c.
(KBiFunctorM k t, Monad m) =>
(k -> a -> m c)
-> (k -> b -> m c) -> (k -> a -> b -> m c) -> t a -> t b -> m (t c)
forall (m :: * -> *) a b c.
Monad m =>
(k -> a -> m c)
-> (k -> b -> m c) -> (k -> a -> b -> m c) -> t a -> t b -> m (t c)
kbimapM k -> a -> m c
f₁ k -> b -> m c
f₂ k -> a -> b -> m c
f₃ t a
xM t b
yM
okbimapMOn ∷ (OKBiFunctorM k t,Monad m) ⇒ t a → t b → (k → a → m (𝑂 c)) → (k → b → m (𝑂 c)) → (k → a → b → m (𝑂 c)) → m (t c)
okbimapMOn :: forall k (t :: * -> *) (m :: * -> *) a b c.
(OKBiFunctorM k t, Monad m) =>
t a
-> t b
-> (k -> a -> m (𝑂 c))
-> (k -> b -> m (𝑂 c))
-> (k -> a -> b -> m (𝑂 c))
-> m (t c)
okbimapMOn = \ t a
xM t b
yM k -> a -> m (𝑂 c)
f₁ k -> b -> m (𝑂 c)
f₂ k -> a -> b -> m (𝑂 c)
f₃ → (k -> a -> m (𝑂 c))
-> (k -> b -> m (𝑂 c))
-> (k -> a -> b -> m (𝑂 c))
-> t a
-> t b
-> m (t c)
forall k (t :: * -> *) (m :: * -> *) a b c.
(OKBiFunctorM k t, Monad m) =>
(k -> a -> m (𝑂 c))
-> (k -> b -> m (𝑂 c))
-> (k -> a -> b -> m (𝑂 c))
-> t a
-> t b
-> m (t c)
forall (m :: * -> *) a b c.
Monad m =>
(k -> a -> m (𝑂 c))
-> (k -> b -> m (𝑂 c))
-> (k -> a -> b -> m (𝑂 c))
-> t a
-> t b
-> m (t c)
okbimapM k -> a -> m (𝑂 c)
f₁ k -> b -> m (𝑂 c)
f₂ k -> a -> b -> m (𝑂 c)
f₃ t a
xM t b
yM
mapOn ∷ (Functor t) ⇒ t a → (a → b) → t b
mapOn :: forall (t :: * -> *) a b. Functor t => t a -> (a -> b) -> t b
mapOn = ((a -> b) -> t a -> t b) -> t a -> (a -> b) -> t b
forall a b c. (a -> b -> c) -> b -> a -> c
flip (a -> b) -> t a -> t b
forall a b. (a -> b) -> t a -> t b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map
mapp ∷ (Functor t,Functor u) ⇒ (a → b) → t (u a) → t (u b)
mapp :: forall (t :: * -> *) (u :: * -> *) a b.
(Functor t, Functor u) =>
(a -> b) -> t (u a) -> t (u b)
mapp = (u a -> u b) -> t (u a) -> t (u b)
forall a b. (a -> b) -> t a -> t b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map ((u a -> u b) -> t (u a) -> t (u b))
-> ((a -> b) -> u a -> u b) -> (a -> b) -> t (u a) -> t (u b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ (a -> b) -> u a -> u b
forall a b. (a -> b) -> u a -> u b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map
mappOn ∷ (Functor t,Functor u) ⇒ t (u a) → (a → b) → t (u b)
mappOn :: forall (t :: * -> *) (u :: * -> *) a b.
(Functor t, Functor u) =>
t (u a) -> (a -> b) -> t (u b)
mappOn = ((a -> b) -> t (u a) -> t (u b)) -> t (u a) -> (a -> b) -> t (u b)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (a -> b) -> t (u a) -> t (u b)
forall (t :: * -> *) (u :: * -> *) a b.
(Functor t, Functor u) =>
(a -> b) -> t (u a) -> t (u b)
mapp
mappp ∷ (Functor t,Functor u,Functor v) ⇒ (a → b) → t (u (v a)) → t (u (v b))
mappp :: forall (t :: * -> *) (u :: * -> *) (v :: * -> *) a b.
(Functor t, Functor u, Functor v) =>
(a -> b) -> t (u (v a)) -> t (u (v b))
mappp = (v a -> v b) -> t (u (v a)) -> t (u (v b))
forall (t :: * -> *) (u :: * -> *) a b.
(Functor t, Functor u) =>
(a -> b) -> t (u a) -> t (u b)
mapp ((v a -> v b) -> t (u (v a)) -> t (u (v b)))
-> ((a -> b) -> v a -> v b)
-> (a -> b)
-> t (u (v a))
-> t (u (v b))
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ (a -> b) -> v a -> v b
forall a b. (a -> b) -> v a -> v b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map
mapppOn ∷ (Functor t,Functor u,Functor v) ⇒ t (u (v a)) → (a → b) → t (u (v b))
mapppOn :: forall (t :: * -> *) (u :: * -> *) (v :: * -> *) a b.
(Functor t, Functor u, Functor v) =>
t (u (v a)) -> (a -> b) -> t (u (v b))
mapppOn = ((a -> b) -> t (u (v a)) -> t (u (v b)))
-> t (u (v a)) -> (a -> b) -> t (u (v b))
forall a b c. (a -> b -> c) -> b -> a -> c
flip (a -> b) -> t (u (v a)) -> t (u (v b))
forall (t :: * -> *) (u :: * -> *) (v :: * -> *) a b.
(Functor t, Functor u, Functor v) =>
(a -> b) -> t (u (v a)) -> t (u (v b))
mappp
(^$) ∷ (Functor t) ⇒ (a → b) → t a → t b
^$ :: forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
(^$) = (a -> b) -> t a -> t b
forall a b. (a -> b) -> t a -> t b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map
(^^$) ∷ (Functor t,Functor u) ⇒ (a → b) → t (u a) → t (u b)
^^$ :: forall (t :: * -> *) (u :: * -> *) a b.
(Functor t, Functor u) =>
(a -> b) -> t (u a) -> t (u b)
(^^$) = (a -> b) -> t (u a) -> t (u b)
forall (t :: * -> *) (u :: * -> *) a b.
(Functor t, Functor u) =>
(a -> b) -> t (u a) -> t (u b)
mapp
(^∘) ∷ (Functor t) ⇒ (b → c) → (a → t b) → a → t c
^∘ :: forall (t :: * -> *) b c a.
Functor t =>
(b -> c) -> (a -> t b) -> a -> t c
(^∘) = \ b -> c
g a -> t b
f → (b -> c) -> t b -> t c
forall a b. (a -> b) -> t a -> t b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map b -> c
g (t b -> t c) -> (a -> t b) -> a -> t c
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ a -> t b
f
(^^∘) ∷ (Functor t,Functor u) ⇒ (b → c) → (a → t (u b)) → a → t (u c)
^^∘ :: forall (t :: * -> *) (u :: * -> *) b c a.
(Functor t, Functor u) =>
(b -> c) -> (a -> t (u b)) -> a -> t (u c)
(^^∘) = \ b -> c
g a -> t (u b)
f → (b -> c) -> t (u b) -> t (u c)
forall (t :: * -> *) (u :: * -> *) a b.
(Functor t, Functor u) =>
(a -> b) -> t (u a) -> t (u b)
mapp b -> c
g (t (u b) -> t (u c)) -> (a -> t (u b)) -> a -> t (u c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ a -> t (u b)
f
omapOn ∷ (OFunctor t) ⇒ t a → (a → 𝑂 b) → t b
omapOn :: forall (t :: * -> *) a b. OFunctor t => t a -> (a -> 𝑂 b) -> t b
omapOn = ((a -> 𝑂 b) -> t a -> t b) -> t a -> (a -> 𝑂 b) -> t b
forall a b c. (a -> b -> c) -> b -> a -> c
flip (a -> 𝑂 b) -> t a -> t b
forall a b. (a -> 𝑂 b) -> t a -> t b
forall (t :: * -> *) a b. OFunctor t => (a -> 𝑂 b) -> t a -> t b
omap
kmapOn ∷ (KFunctor k t) ⇒ t a → (k → a → b) → t b
kmapOn :: forall k (t :: * -> *) a b.
KFunctor k t =>
t a -> (k -> a -> b) -> t b
kmapOn = ((k -> a -> b) -> t a -> t b) -> t a -> (k -> a -> b) -> t b
forall a b c. (a -> b -> c) -> b -> a -> c
flip (k -> a -> b) -> t a -> t b
forall a b. (k -> a -> b) -> t a -> t b
forall k (t :: * -> *) a b.
KFunctor k t =>
(k -> a -> b) -> t a -> t b
kmap
kmapAtOn ∷ (KFunctor k t) ⇒ k → t a → (a → a) → t a
kmapAtOn :: forall k (t :: * -> *) a.
KFunctor k t =>
k -> t a -> (a -> a) -> t a
kmapAtOn = ((a -> a) -> t a -> t a) -> t a -> (a -> a) -> t a
forall a b c. (a -> b -> c) -> b -> a -> c
flip (((a -> a) -> t a -> t a) -> t a -> (a -> a) -> t a)
-> (k -> (a -> a) -> t a -> t a) -> k -> t a -> (a -> a) -> t a
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ k -> (a -> a) -> t a -> t a
forall a. k -> (a -> a) -> t a -> t a
forall k (t :: * -> *) a.
KFunctor k t =>
k -> (a -> a) -> t a -> t a
kmapAt
okmapOn ∷ (OKFunctor k t) ⇒ t a → (k → a → 𝑂 b) → t b
okmapOn :: forall k (t :: * -> *) a b.
OKFunctor k t =>
t a -> (k -> a -> 𝑂 b) -> t b
okmapOn = ((k -> a -> 𝑂 b) -> t a -> t b) -> t a -> (k -> a -> 𝑂 b) -> t b
forall a b c. (a -> b -> c) -> b -> a -> c
flip (k -> a -> 𝑂 b) -> t a -> t b
forall a b. (k -> a -> 𝑂 b) -> t a -> t b
forall k (t :: * -> *) a b.
OKFunctor k t =>
(k -> a -> 𝑂 b) -> t a -> t b
okmap
okmapAtOn ∷ (OKFunctor k t) ⇒ k → t a → (𝑂 a → 𝑂 a) → t a
okmapAtOn :: forall k (t :: * -> *) a.
OKFunctor k t =>
k -> t a -> (𝑂 a -> 𝑂 a) -> t a
okmapAtOn = ((𝑂 a -> 𝑂 a) -> t a -> t a) -> t a -> (𝑂 a -> 𝑂 a) -> t a
forall a b c. (a -> b -> c) -> b -> a -> c
flip (((𝑂 a -> 𝑂 a) -> t a -> t a) -> t a -> (𝑂 a -> 𝑂 a) -> t a)
-> (k -> (𝑂 a -> 𝑂 a) -> t a -> t a)
-> k
-> t a
-> (𝑂 a -> 𝑂 a)
-> t a
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ k -> (𝑂 a -> 𝑂 a) -> t a -> t a
forall a. k -> (𝑂 a -> 𝑂 a) -> t a -> t a
forall k (t :: * -> *) a.
OKFunctor k t =>
k -> (𝑂 a -> 𝑂 a) -> t a -> t a
okmapAt
bimapOn ∷ (BiFunctor t) ⇒ t a → t b → (a → c) → (b → c) → (a → b → c) → t c
bimapOn :: forall (t :: * -> *) a b c.
BiFunctor t =>
t a -> t b -> (a -> c) -> (b -> c) -> (a -> b -> c) -> t c
bimapOn = \ t a
x t b
y a -> c
f₁ b -> c
f₂ a -> b -> c
f₃ → (a -> c) -> (b -> c) -> (a -> b -> c) -> t a -> t b -> t c
forall a c b.
(a -> c) -> (b -> c) -> (a -> b -> c) -> t a -> t b -> t c
forall (t :: * -> *) a c b.
BiFunctor t =>
(a -> c) -> (b -> c) -> (a -> b -> c) -> t a -> t b -> t c
bimap a -> c
f₁ b -> c
f₂ a -> b -> c
f₃ t a
x t b
y
obimapOn ∷ (OBiFunctor t) ⇒ t a → t b → (a → 𝑂 c) → (b → 𝑂 c) → (a → b → 𝑂 c) → t c
obimapOn :: forall (t :: * -> *) a b c.
OBiFunctor t =>
t a -> t b -> (a -> 𝑂 c) -> (b -> 𝑂 c) -> (a -> b -> 𝑂 c) -> t c
obimapOn = \ t a
x t b
y a -> 𝑂 c
f₁ b -> 𝑂 c
f₂ a -> b -> 𝑂 c
f₃ → (a -> 𝑂 c) -> (b -> 𝑂 c) -> (a -> b -> 𝑂 c) -> t a -> t b -> t c
forall a c b.
(a -> 𝑂 c) -> (b -> 𝑂 c) -> (a -> b -> 𝑂 c) -> t a -> t b -> t c
forall (t :: * -> *) a c b.
OBiFunctor t =>
(a -> 𝑂 c) -> (b -> 𝑂 c) -> (a -> b -> 𝑂 c) -> t a -> t b -> t c
obimap a -> 𝑂 c
f₁ b -> 𝑂 c
f₂ a -> b -> 𝑂 c
f₃ t a
x t b
y
kbimapOn ∷ (KBiFunctor k t) ⇒ t a → t b → (k → a → c) → (k → b → c) → (k → a → b → c) → t c
kbimapOn :: forall k (t :: * -> *) a b c.
KBiFunctor k t =>
t a
-> t b
-> (k -> a -> c)
-> (k -> b -> c)
-> (k -> a -> b -> c)
-> t c
kbimapOn = \ t a
x t b
y k -> a -> c
f₁ k -> b -> c
f₂ k -> a -> b -> c
f₃ → (k -> a -> c)
-> (k -> b -> c) -> (k -> a -> b -> c) -> t a -> t b -> t c
forall a c b.
(k -> a -> c)
-> (k -> b -> c) -> (k -> a -> b -> c) -> t a -> t b -> t c
forall k (t :: * -> *) a c b.
KBiFunctor k t =>
(k -> a -> c)
-> (k -> b -> c) -> (k -> a -> b -> c) -> t a -> t b -> t c
kbimap k -> a -> c
f₁ k -> b -> c
f₂ k -> a -> b -> c
f₃ t a
x t b
y
okbimapOn ∷ (OKBiFunctor k t) ⇒ t a → t b → (k → a → 𝑂 c) → (k → b → 𝑂 c) → (k → a → b → 𝑂 c) → t c
okbimapOn :: forall k (t :: * -> *) a b c.
OKBiFunctor k t =>
t a
-> t b
-> (k -> a -> 𝑂 c)
-> (k -> b -> 𝑂 c)
-> (k -> a -> b -> 𝑂 c)
-> t c
okbimapOn = \ t a
x t b
y k -> a -> 𝑂 c
f₁ k -> b -> 𝑂 c
f₂ k -> a -> b -> 𝑂 c
f₃ → (k -> a -> 𝑂 c)
-> (k -> b -> 𝑂 c) -> (k -> a -> b -> 𝑂 c) -> t a -> t b -> t c
forall a c b.
(k -> a -> 𝑂 c)
-> (k -> b -> 𝑂 c) -> (k -> a -> b -> 𝑂 c) -> t a -> t b -> t c
forall k (t :: * -> *) a c b.
OKBiFunctor k t =>
(k -> a -> 𝑂 c)
-> (k -> b -> 𝑂 c) -> (k -> a -> b -> 𝑂 c) -> t a -> t b -> t c
okbimap k -> a -> 𝑂 c
f₁ k -> b -> 𝑂 c
f₂ k -> a -> b -> 𝑂 c
f₃ t a
x t b
y
class Functor2 (w ∷ (★ → ★) → (★ → ★)) where map2 ∷ (t →⁻ u) → w t →⁻ w u
class Functor2Iso (w ∷ (★ → ★) → (★ → ★)) where map2iso ∷ Iso2 t u → w t →⁻ w u
(>>=) ∷ (Bind m) ⇒ m a → (a → m b) → m b
>>= :: forall (m :: * -> *) a b. Bind m => m a -> (a -> m b) -> m b
(>>=) = m a -> (a -> m b) -> m b
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Bind m => m a -> (a -> m b) -> m b
(≫=)
(>>) ∷ (Bind m) ⇒ m a → m b → m b
>> :: forall (m :: * -> *) a b. Bind m => m a -> m b -> m b
(>>) = \ m a
xM ~m b
yM → m a
xM m a -> (a -> m b) -> m b
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Bind m => m a -> (a -> m b) -> m b
≫= \ a
_ → m b -> m b
forall a. a -> a
id m b
yM
class Return (m ∷ ★ → ★) where return ∷ a → m a
class Bind (m ∷ ★ → ★) where (≫=) ∷ m a → (a → m b) → m b
class (Functor m,Return m,Bind m) ⇒ Monad m
class Transformer (t ∷ (★ → ★) → (★ → ★)) where lift ∷ ∀ m a. (Monad m) ⇒ m a → t m a
(*⋅) ∷ (Bind m) ⇒ (a → m b) → (m a → m b)
*⋅ :: forall (m :: * -> *) a b. Bind m => (a -> m b) -> m a -> m b
(*⋅) = (a -> m b) -> m a -> m b
forall (m :: * -> *) a b. Bind m => (a -> m b) -> m a -> m b
extend
(*$) ∷ (Bind m) ⇒ (a → m b) → (m a → m b)
*$ :: forall (m :: * -> *) a b. Bind m => (a -> m b) -> m a -> m b
(*$) = (a -> m b) -> m a -> m b
forall (m :: * -> *) a b. Bind m => (a -> m b) -> m a -> m b
extend
(*∘) ∷ (Bind m) ⇒ (b → m c) → (a → m b) → (a → m c)
*∘ :: forall (m :: * -> *) b c a.
Bind m =>
(b -> m c) -> (a -> m b) -> a -> m c
(*∘) = \ b -> m c
g a -> m b
f → (b -> m c) -> m b -> m c
forall (m :: * -> *) a b. Bind m => (a -> m b) -> m a -> m b
extend b -> m c
g (m b -> m c) -> (a -> m b) -> a -> m c
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ a -> m b
f
kreturn ∷ (Return m) ⇒ (a → b) → (a → m b)
kreturn :: forall (m :: * -> *) a b. Return m => (a -> b) -> a -> m b
kreturn = \ a -> b
f → b -> m b
forall a. a -> m a
forall (m :: * -> *) a. Return m => a -> m a
return (b -> m b) -> (a -> b) -> a -> m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ a -> b
f
extend ∷ (Bind m) ⇒ (a → m b) → (m a → m b)
extend :: forall (m :: * -> *) a b. Bind m => (a -> m b) -> m a -> m b
extend = \ a -> m b
f m a
xM → m a
xM m a -> (a -> m b) -> m b
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Bind m => m a -> (a -> m b) -> m b
≫= a -> m b
f
(≫) ∷ (Bind m) ⇒ m a → m b → m b
≫ :: forall (m :: * -> *) a b. Bind m => m a -> m b -> m b
(≫) = \ m a
xM ~m b
yM → m a
xM m a -> (a -> m b) -> m b
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Bind m => m a -> (a -> m b) -> m b
≫= \ a
_ → m b -> m b
forall a. a -> a
id m b
yM
void ∷ (Functor m) ⇒ m a → m ()
void :: forall (m :: * -> *) a. Functor m => m a -> m ()
void = (a -> ()) -> m a -> m ()
forall a b. (a -> b) -> m a -> m b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map ((a -> ()) -> m a -> m ()) -> (a -> ()) -> m a -> m ()
forall a b. (a -> b) -> a -> b
$ () -> a -> ()
forall a b. a -> b -> a
const ()
mjoin ∷ (Bind m) ⇒ m (m a) → m a
mjoin :: forall (m :: * -> *) a. Bind m => m (m a) -> m a
mjoin = (m a -> m a) -> m (m a) -> m a
forall (m :: * -> *) a b. Bind m => (a -> m b) -> m a -> m b
extend m a -> m a
forall a. a -> a
id
mmap ∷ (Monad m) ⇒ (a → b) → m a → m b
mmap :: forall (m :: * -> *) a b. Monad m => (a -> b) -> m a -> m b
mmap = \ a -> b
f m a
xM → do a
x ← m a
xM ; b -> m b
forall a. a -> m a
forall (m :: * -> *) a. Return m => a -> m a
return (b -> m b) -> b -> m b
forall a b. (a -> b) -> a -> b
$ a -> b
f a
x
(⧆) ∷ (Monad m) ⇒ m a → m b → m (a ∧ b)
⧆ :: forall (m :: * -> *) a b. Monad m => m a -> m b -> m (a ∧ b)
(⧆) = \ m a
xM m b
yM → do a
x ← m a
xM ; b
y ← m b
yM ; (a ∧ b) -> m (a ∧ b)
forall a. a -> m a
forall (m :: * -> *) a. Return m => a -> m a
return ((a ∧ b) -> m (a ∧ b)) -> (a ∧ b) -> m (a ∧ b)
forall a b. (a -> b) -> a -> b
$ a
x a -> b -> a ∧ b
forall a b. a -> b -> a ∧ b
:* b
y
(⊡) ∷ (Monad m) ⇒ m (a → b) → m a → m b
⊡ :: forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
(⊡) = \ m (a -> b)
fM m a
xM → do a -> b
f ← m (a -> b)
fM ; a
x ← m a
xM ; b -> m b
forall a. a -> m a
forall (m :: * -> *) a. Return m => a -> m a
return (b -> m b) -> b -> m b
forall a b. (a -> b) -> a -> b
$ a -> b
f a
x
skip ∷ (Return m) ⇒ m ()
skip :: forall (m :: * -> *). Return m => m ()
skip = () -> m ()
forall a. a -> m a
forall (m :: * -> *) a. Return m => a -> m a
return ()
when ∷ (Return m) ⇒ 𝔹 → (() → m ()) → m ()
when :: forall (m :: * -> *). Return m => 𝔹 -> (() -> m ()) -> m ()
when = \ 𝔹
b () -> m ()
f → if 𝔹
b then () -> m ()
f () else m ()
forall (m :: * -> *). Return m => m ()
skip
whenM ∷ (Monad m) ⇒ m 𝔹 → (() → m ()) → m ()
whenM :: forall (m :: * -> *). Monad m => m 𝔹 -> (() -> m ()) -> m ()
whenM = \ m 𝔹
bM () -> m ()
xM → do 𝔹
b ← m 𝔹
bM ; 𝔹 -> (() -> m ()) -> m ()
forall (m :: * -> *). Return m => 𝔹 -> (() -> m ()) -> m ()
when 𝔹
b () -> m ()
xM
newtype ToHSM (m ∷ ★ → ★) (a ∷ ★) = ToHSM { forall (m :: * -> *) a. ToHSM m a -> m a
unToHSM ∷ m a }
instance (Functor t) ⇒ HS.Functor (ToHSM t) where
fmap :: forall a b. (a -> b) -> ToHSM t a -> ToHSM t b
fmap a -> b
f = t b -> ToHSM t b
forall (m :: * -> *) a. m a -> ToHSM m a
ToHSM (t b -> ToHSM t b) -> (t a -> t b) -> t a -> ToHSM t b
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ (a -> b) -> t a -> t b
forall a b. (a -> b) -> t a -> t b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map a -> b
f (t a -> ToHSM t b) -> (ToHSM t a -> t a) -> ToHSM t a -> ToHSM t b
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ ToHSM t a -> t a
forall (m :: * -> *) a. ToHSM m a -> m a
unToHSM
instance (Monad m) ⇒ HS.Applicative (ToHSM m) where
pure :: forall a. a -> ToHSM m a
pure = m a -> ToHSM m a
forall (m :: * -> *) a. m a -> ToHSM m a
ToHSM (m a -> ToHSM m a) -> (a -> m a) -> a -> ToHSM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ a -> m a
forall a. a -> m a
forall (m :: * -> *) a. Return m => a -> m a
return
ToHSM m (a -> b)
fM <*> :: forall a b. ToHSM m (a -> b) -> ToHSM m a -> ToHSM m b
<*> ToHSM m a
xM = m b -> ToHSM m b
forall (m :: * -> *) a. m a -> ToHSM m a
ToHSM (m b -> ToHSM m b) -> m b -> ToHSM m b
forall a b. (a -> b) -> a -> b
$ ToHSM m (a -> b) -> m (a -> b)
forall (m :: * -> *) a. ToHSM m a -> m a
unToHSM ToHSM m (a -> b)
fM m (a -> b) -> m a -> m b
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
⊡ ToHSM m a -> m a
forall (m :: * -> *) a. ToHSM m a -> m a
unToHSM ToHSM m a
xM
instance (Monad m) ⇒ HS.Monad (ToHSM m) where
ToHSM m a
xM >>= :: forall a b. ToHSM m a -> (a -> ToHSM m b) -> ToHSM m b
>>= a -> ToHSM m b
f = m b -> ToHSM m b
forall (m :: * -> *) a. m a -> ToHSM m a
ToHSM (m b -> ToHSM m b) -> m b -> ToHSM m b
forall a b. (a -> b) -> a -> b
$ do
a
x ← ToHSM m a -> m a
forall (m :: * -> *) a. ToHSM m a -> m a
unToHSM ToHSM m a
xM
ToHSM m b -> m b
forall (m :: * -> *) a. ToHSM m a -> m a
unToHSM (ToHSM m b -> m b) -> ToHSM m b -> m b
forall a b. (a -> b) -> a -> b
$ a -> ToHSM m b
f a
x
tohsMonad ∷ ∀ m. (Monad m) ⇒ W (HS.Monad m)
tohsMonad :: forall (m :: * -> *). Monad m => W (Monad m)
tohsMonad = W (Monad (ToHSM m)) -> W (Monad m)
forall a b. a -> b
coerce_UNSAFE (W (Monad (ToHSM m))
forall (c :: Constraint). c => W c
W ∷ W (HS.Monad (ToHSM m)))
newtype FrHSM (m ∷ ★ → ★) (a ∷ ★) = FrHSM { forall (m :: * -> *) a. FrHSM m a -> m a
unFrHSM ∷ m a }
instance (HS.Functor t) ⇒ Functor (FrHSM t) where
map :: forall a b. (a -> b) -> FrHSM t a -> FrHSM t b
map a -> b
f = t b -> FrHSM t b
forall (m :: * -> *) a. m a -> FrHSM m a
FrHSM (t b -> FrHSM t b) -> (t a -> t b) -> t a -> FrHSM t b
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ (a -> b) -> t a -> t b
forall a b. (a -> b) -> t a -> t b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
HS.fmap a -> b
f (t a -> FrHSM t b) -> (FrHSM t a -> t a) -> FrHSM t a -> FrHSM t b
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ FrHSM t a -> t a
forall (m :: * -> *) a. FrHSM m a -> m a
unFrHSM
instance (HS.Monad m) ⇒ Return (FrHSM m) where
return :: forall a. a -> FrHSM m a
return = m a -> FrHSM m a
forall (m :: * -> *) a. m a -> FrHSM m a
FrHSM (m a -> FrHSM m a) -> (a -> m a) -> a -> FrHSM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
∘ a -> m a
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
HS.return
instance (HS.Monad m) ⇒ Bind (FrHSM m) where
FrHSM m a
xM ≫= :: forall a b. FrHSM m a -> (a -> FrHSM m b) -> FrHSM m b
≫= a -> FrHSM m b
f = m b -> FrHSM m b
forall (m :: * -> *) a. m a -> FrHSM m a
FrHSM (m b -> FrHSM m b) -> m b -> FrHSM m b
forall a b. (a -> b) -> a -> b
$ FrHSM m a -> m a
forall (m :: * -> *) a. FrHSM m a -> m a
unFrHSM FrHSM m a
xM m a -> (a -> m b) -> m b
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
HS.>>= \ a
x → FrHSM m b -> m b
forall (m :: * -> *) a. FrHSM m a -> m a
unFrHSM (FrHSM m b -> m b) -> FrHSM m b -> m b
forall a b. (a -> b) -> a -> b
$ a -> FrHSM m b
f a
x
instance (HS.Monad m) ⇒ Monad (FrHSM m)
frhsMonad ∷ ∀ m. (HS.Monad m) ⇒ W (Monad m)
frhsMonad :: forall (m :: * -> *). Monad m => W (Monad m)
frhsMonad = W (Monad (FrHSM m)) -> W (Monad m)
forall a b. a -> b
coerce_UNSAFE (W (Monad (FrHSM m))
forall (c :: Constraint). c => W c
W ∷ W (Monad (FrHSM m)))