module Pandora.Pattern.Functor.Traversable where
import Pandora.Core.Functor (type (:.), type (:=))
import Pandora.Pattern.Functor.Covariant (Covariant)
import Pandora.Pattern.Functor.Applicative (Applicative)
import Pandora.Pattern.Functor.Pointable (Pointable)
infixl 5 ->>, ->>>, ->>>>, ->>>>>
class Covariant t => Traversable t where
{-# MINIMAL (->>) #-}
(->>) :: (Pointable u, Applicative u) => t a -> (a -> u b) -> u :. t := b
traverse :: (Pointable u, Applicative u) => (a -> u b) -> t a -> u :. t := b
traverse a -> u b
f t a
t = t a
t t a -> (a -> u b) -> (u :. t) := b
forall (t :: * -> *) (u :: * -> *) a b.
(Traversable t, Pointable u, Applicative u) =>
t a -> (a -> u b) -> (u :. t) := b
->> a -> u b
f
sequence :: (Pointable u, Applicative u) => t :. u := a -> u :. t := a
sequence (t :. u) := a
t = (t :. u) := a
t ((t :. u) := a) -> (u a -> u a) -> (u :. t) := a
forall (t :: * -> *) (u :: * -> *) a b.
(Traversable t, Pointable u, Applicative u) =>
t a -> (a -> u b) -> (u :. t) := b
->> (\u a
x -> u a
x)
(->>>) :: (Pointable u, Applicative u, Traversable v)
=> v :. t := a -> (a -> u b) -> u :. v :. t := b
(v :. t) := a
x ->>> a -> u b
f = (v :. t) := a
x ((v :. t) := a) -> (t a -> u (t b)) -> (u :. (v :. t)) := b
forall (t :: * -> *) (u :: * -> *) a b.
(Traversable t, Pointable u, Applicative u) =>
t a -> (a -> u b) -> (u :. t) := b
->> (t a -> (a -> u b) -> u (t b)
forall (t :: * -> *) (u :: * -> *) a b.
(Traversable t, Pointable u, Applicative u) =>
t a -> (a -> u b) -> (u :. t) := b
->> a -> u b
f)
(->>>>) :: (Pointable u, Applicative u, Traversable v, Traversable w)
=> w :. v :. t := a -> (a -> u b) -> u :. w :. v :. t := b
(w :. (v :. t)) := a
x ->>>> a -> u b
f = (w :. (v :. t)) := a
x ((w :. (v :. t)) := a)
-> ((:.) v t a -> u (v (t b))) -> (u :. (w :. (v :. t))) := b
forall (t :: * -> *) (u :: * -> *) a b.
(Traversable t, Pointable u, Applicative u) =>
t a -> (a -> u b) -> (u :. t) := b
->> ((:.) v t a -> (t a -> u (t b)) -> u (v (t b))
forall (t :: * -> *) (u :: * -> *) a b.
(Traversable t, Pointable u, Applicative u) =>
t a -> (a -> u b) -> (u :. t) := b
->> (t a -> (a -> u b) -> u (t b)
forall (t :: * -> *) (u :: * -> *) a b.
(Traversable t, Pointable u, Applicative u) =>
t a -> (a -> u b) -> (u :. t) := b
->> a -> u b
f))
(->>>>>) :: (Pointable u, Applicative u, Traversable v, Traversable w, Traversable j)
=> j :. w :. v :. t := a -> (a -> u b) -> u :. j :. w :. v :. t := b
(j :. (w :. (v :. t))) := a
x ->>>>> a -> u b
f = (j :. (w :. (v :. t))) := a
x ((j :. (w :. (v :. t))) := a)
-> ((:.) w (v :. t) a -> u (w (v (t b))))
-> (u :. (j :. (w :. (v :. t)))) := b
forall (t :: * -> *) (u :: * -> *) a b.
(Traversable t, Pointable u, Applicative u) =>
t a -> (a -> u b) -> (u :. t) := b
->> ((:.) w (v :. t) a -> ((:.) v t a -> u (v (t b))) -> u (w (v (t b)))
forall (t :: * -> *) (u :: * -> *) a b.
(Traversable t, Pointable u, Applicative u) =>
t a -> (a -> u b) -> (u :. t) := b
->> ((:.) v t a -> (t a -> u (t b)) -> u (v (t b))
forall (t :: * -> *) (u :: * -> *) a b.
(Traversable t, Pointable u, Applicative u) =>
t a -> (a -> u b) -> (u :. t) := b
->> (t a -> (a -> u b) -> u (t b)
forall (t :: * -> *) (u :: * -> *) a b.
(Traversable t, Pointable u, Applicative u) =>
t a -> (a -> u b) -> (u :. t) := b
->> a -> u b
f)))