dorchard / effect-monad

Provides 'graded monads' and 'parameterised monads' to Haskell, enabling fine-grained reasoning about effects.
BSD 2-Clause "Simplified" License
99 stars 11 forks source link

Add (Kleisli) Arrows #11

Open turion opened 6 years ago

turion commented 6 years ago

We could define Kleisli as:

newtype Kleisli m f a b = Kleisli { runKleisli :: a -> m f b }

It would be an instance of a generalised Arrow instance which would yet have to be defined.

turion commented 6 years ago

The corresponding Arrow type class would look something like:

class CategoryEffect (cat :: k -> * -> * -> *) where
  type Unit cat :: k
  type Plus cat (f :: k) (g :: k) :: k
  type Inv cat (f :: k) (g :: k) :: Constraint
  type Inv cat f g = ()

  id :: cat (Unit cat) a a
  (>>>) :: Inv cat f g => cat f a b -> cat g b c -> cat (Plus cat f g) a c

class CategoryEffect a => ArrowEffect (a :: k -> * -> * -> *) where
  arr :: (b -> c) -> a (Unit a) b c
  first :: a f b c -> a f (b, d) (c, d)
dorchard commented 3 years ago

Cool idea! Let's do it! Do you want to a PR or should I move this code into a new module?

turion commented 3 years ago

I can make a PR.