module Data.Profunctor.Static (StaticProfunctor(..)) where
import Control.Distributed.Closure
import Data.Typeable (Typeable)
class Typeable p => StaticProfunctor p where
staticDimap
:: (Typeable a, Typeable b, Typeable c, Typeable d)
=> Closure (a -> b) -> Closure (c -> d) -> p b c -> p a d
staticDimap sf sg = staticLmap sf . staticRmap sg
staticLmap
:: (Typeable a, Typeable b, Typeable c)
=> Closure (a -> b) -> p b c -> p a c
staticLmap sf = staticDimap sf (static id)
staticRmap
:: (Typeable a, Typeable c, Typeable d)
=> Closure (c -> d) -> p a c -> p a d
staticRmap sg = staticDimap (static id) sg
staticCompose
:: (Typeable a, Typeable b, Typeable c)
=> Closure (b -> c) -> Closure (a -> b) -> Closure (a -> c)
staticCompose f g = static (.) `cap` f `cap` g
instance StaticProfunctor WrappedArrowClosure where
staticDimap sf sg (WrapArrowClosure sk) =
WrapArrowClosure (sg `staticCompose` sk `staticCompose` sf)