garyb / purescript-indexed-monad

MIT License
21 stars 11 forks source link

Overhaul hierarchy to match control, drop Aff/Eff, add Indexed #12

Closed garyb closed 5 years ago

garyb commented 6 years ago

/cc @owickstrom well, I got there eventually... Data.Indexed is the IxM type I mentioned in #11

How does this all look? I think you're the primary user of the library right now, so don't know who else is out there that might have opinions on it :smile:

I think Indexed provides enough stuff that it won't be too annoying to have all of the intermediate classes, since everything can be derive newtype instance'd.

owickstrom commented 6 years ago

All the Control.*.Indexed stuff looks great. I haven't had the time to try it for purescript-leffe or Hyper, but looks reasonable.

The Indexed type is not obvious to me. Is it for running an indexed computation with a regular monad?

Also, should there be instances for the regular hierarchy of Functor, Apply, Applicative, and Bind, for Indexed?

garyb commented 6 years ago

Yeah Indexed is for defining things like the old IxAff / IxEff, where you want a "phantom indexed monad" kinda thing:

newtype IxAff eff i o a = IxAff (Indexed (Aff eff) i o a)

derive newtype instance ixFunctorIndexed ∷ IxFunctor (IxAff eff)
derive newtype instance ixApplyIndexed ∷ IxApply (IxAff eff)
derive newtype instance ixApplicativeIndexed ∷ IxApplicative (IxAff eff)
derive newtype instance ixBindIndexed ∷ IxBind (IxAff eff)
derive newtype instance ixMonadIndexed ∷ IxMonad (IxAff eff)

So yes, lifting a non-indexed monad into being indexed. Which may not be entirely useless, as you could still track things in the types there, to ensure a connection is closed or whatever... or... I don't know, maybe it is useless :smile:

garyb commented 6 years ago

Maybe we should include the indexed state transformer in here too, since that's what Middleware and Leffe both are, isn't it?

leighman commented 5 years ago

Maybe we should include the indexed state transformer in here too, since that's what Middleware and Leffe both are, isn't it?

Also rolling my own IxStateT. Seems like it would be good to have here.