module Pandora.Paradigm.Primary.Functor.Edges where import Pandora.Pattern.Category (($)) import Pandora.Pattern.Functor.Covariant (Covariant ((<-|-))) import Pandora.Pattern.Functor.Traversable (Traversable ((<<-))) import Pandora.Paradigm.Primary.Algebraic.Exponential () import Pandora.Paradigm.Primary.Algebraic (point) data Edges a = Empty | Leap a | Connect a | Overlay a instance Covariant (->) (->) Edges where a -> b _ <-|- :: (a -> b) -> Edges a -> Edges b <-|- Edges a Empty = Edges b forall a. Edges a Empty a -> b f <-|- Connect a x = b -> Edges b forall a. a -> Edges a Connect (b -> Edges b) -> b -> Edges b forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b) $ a -> b f a x a -> b f <-|- Overlay a x = b -> Edges b forall a. a -> Edges a Overlay (b -> Edges b) -> b -> Edges b forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b) $ a -> b f a x a -> b f <-|- Leap a x = b -> Edges b forall a. a -> Edges a Leap (b -> Edges b) -> b -> Edges b forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b) $ a -> b f a x instance Traversable (->) (->) Edges where a -> u b _ <<- :: (a -> u b) -> Edges a -> u (Edges b) <<- Edges a Empty = Edges b -> u (Edges b) forall (t :: * -> *) a. Pointable t => a -> t a point Edges b forall a. Edges a Empty a -> u b f <<- Connect a x = b -> Edges b forall a. a -> Edges a Connect (b -> Edges b) -> u b -> u (Edges b) forall (source :: * -> * -> *) (target :: * -> * -> *) (t :: * -> *) a b. Covariant source target t => source a b -> target (t a) (t b) <-|- a -> u b f a x a -> u b f <<- Overlay a x = b -> Edges b forall a. a -> Edges a Overlay (b -> Edges b) -> u b -> u (Edges b) forall (source :: * -> * -> *) (target :: * -> * -> *) (t :: * -> *) a b. Covariant source target t => source a b -> target (t a) (t b) <-|- a -> u b f a x a -> u b f <<- Leap a x = b -> Edges b forall a. a -> Edges a Leap (b -> Edges b) -> u b -> u (Edges b) forall (source :: * -> * -> *) (target :: * -> * -> *) (t :: * -> *) a b. Covariant source target t => source a b -> target (t a) (t b) <-|- a -> u b f a x edges :: r -> (a -> r) -> (a -> r) -> (a -> r) -> Edges a -> r edges :: r -> (a -> r) -> (a -> r) -> (a -> r) -> Edges a -> r edges r r a -> r _ a -> r _ a -> r _ Edges a Empty = r r edges r _ a -> r f a -> r _ a -> r _ (Connect a x) = a -> r f a x edges r _ a -> r _ a -> r g a -> r _ (Overlay a y) = a -> r g a y edges r _ a -> r _ a -> r _ a -> r h (Leap a z) = a -> r h a z