On Thu, May 24, 2012 at 7:42 AM, Normen Müller
<
normen....@googlemail.com> wrote:
> Hi Jason,
>
> Thanks for your reply! Got it.
>
> But why don't we need that explicit typing using Scalaz (ExampleFunctor):
>
>
> // Map across the Function1 functor
>
> val len = (s: String) => s.length
>
> (len ∘ (1 + (_: Int))).apply("foo") assert_=== 4
>
> Cheers,
> /nm
We first implicitly convert (I => O) to MA[[a](I => a), O]*. We wrote
a bunch conversions like this for various binary (and higher arity)
type constructors, e.g. Function2, Tuple3. (A single implicit suffices
for type constructor like List/Option, as the compiler can infer M.)
Inside MA, we define the method ∘, which can access the type
constructor M without further inference.
scalaz-seven uses Unapply, which means we only have to write a
conversion for each kind, rather than for each type based on a
non-unary type constructor. This was especially important, as we no
longer put all these methods in the monolithic MA, but rather spread
them into FunctorOps / MonadOps etc.
-jason