> // TODO which we need to have access to the i...
# arrow
p
// TODO which we need to have access to the implementation of map in Option
yes! it's also a fun exercise not to call
fix()
and see a stackoverflow exception because the function calls itself
đŸ˜‚ 1
j
I've learned to really appreaciate the recursion icon intellij shows in these cases as sometimes even with
.fix()
this can happen (if the ext. function is also on to
Kind<*, *>
) ^^ Probably saved me many minutes of pointless staring at code
b
another question:
Copy code
fun <F> parseInt(value: Kind<F, Int>, functor: Functor<F>) =
    functor.run {
        value.map { it.toInt() }
    }
I have trouble with this run method... If we had a way of saying
Kind<F extends Functor, Int>
would it be possible to just say:
Copy code
fun <F> parseInt(value: Kind<F extends Functor, Int>) = value.map { it.toInt() }
p
that’s the thing, the fact that you have to pass a
Functor<F>
proves that one exists
now, typeclasses, or extension interfaces, or traits, or whatever the name your lang/framework uses
is the mechanism to inject that parameter you want
F: Functor[_]
is in fact one way Scala does it
the current state of the art is
Copy code
fun <F> Functor<F>.parseInt(value: Kind<F extends Functor, Int>) =
and the next generation is what the compiler plugin will do
what we call sometimes KEEP87
b
awesome thanks for the response!