module Pandora.Paradigm.Controlflow.Effect.Interpreted where

import Pandora.Pattern.Category ((.))
import Pandora.Pattern.Functor.Covariant (Covariant)
import Pandora.Pattern.Transformer.Liftable (Liftable (lift))

type family Schematic (c :: (* -> *) -> k) (t :: * -> *) = (r :: (* -> *) -> * -> *) | r -> t

class Interpreted t where
	{-# MINIMAL run, unite #-}
	type Primary t a :: *
	run :: t a -> Primary t a
	unite :: Primary t a -> t a

	(||=) :: (Primary t a -> Primary t b) -> t a -> t b
	(||=) Primary t a -> Primary t b
f = Primary t b -> t b
forall (t :: * -> *) a. Interpreted t => Primary t a -> t a
unite (Primary t b -> t b) -> (t a -> Primary t b) -> t a -> t b
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Primary t a -> Primary t b
f (Primary t a -> Primary t b)
-> (t a -> Primary t a) -> t a -> Primary t b
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. t a -> Primary t a
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run

(-=:) :: (Liftable t, Interpreted (t u), Interpreted (t v), Covariant u)
	=> (t u a -> t v b) -> u a -> Primary (t v) b
-=: :: (t u a -> t v b) -> u a -> Primary (t v) b
(-=:) t u a -> t v b
f = t v b -> Primary (t v) b
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run (t v b -> Primary (t v) b)
-> (u a -> t v b) -> u a -> Primary (t v) b
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. t u a -> t v b
f (t u a -> t v b) -> (u a -> t u a) -> u a -> t v b
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. u a -> t u a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant u) =>
u ~> t u
lift