[Haskell-cafe] Can it be proven there are no intermediate "useful" type classes between Applicative Functors & Monads?
syntaxglitch at gmail.com
Tue Jun 7 01:05:15 CEST 2011
On Mon, Jun 6, 2011 at 5:32 PM, Matthew Steele <mdsteele at alum.mit.edu> wrote:
> I think Branching is to Monad what ArrowChoice is to ArrowApply.
> Branching allows the shape of the computation to depend on run-time
> values (which you can't do with Applicative), but still allows only a
> finite number of computation paths. By purposely making a functor an
> instance of Branching but _not_ of Monad, you allow it to have some
> amount of run-time flexibility while still retaining the ability to
> "statically" analyze the effects of a computation in that functor.
Yes, that's what I gathered as well. It's a straightforward concept.
My question is whether there exist instances of Branching that are
distinct in results from an implementation in terms of a Monad
instance, rather than merely allowing a more efficient implementation.
Not that the latter isn't worthwhile, but to make a case for something
like Branching as an intermediate between Applicative and Monad one
would expect it to differ from both in what types have possible
ArrowChoice and ArrowApply are conceptually distinct and I expect
there are instances of the former that have no possible instance for
the latter. Branching vs. Monad I am much less certain of.
>> branchApplicative = liftA3 (\b t f -> if b then t else f)
> This definition doesn't satisfy the laws given for the Branching
> class; it will execute the effects of both branches regardless of
> which is chosen.
How would it violate the laws for Identity or Reader?
More information about the Haskell-Cafe