Jannis
12/22/2019, 10:48 PMStateT<F, S, A>
is defined with Kind<F, (S) -> Kind<F, Tuple2<S, A>>>
? The double Kind<F, *>
are weird. I am currently rewriting some tests for higher coverage and noticed a bunch of failures with monad-applicative-consistency (monad derived ap doing different things than normal ap) and StateT
is the last one that still fails.raulraja
12/22/2019, 11:05 PMraulraja
12/22/2019, 11:06 PMJannis
12/22/2019, 11:27 PMflatMap
will only map
over top Kind<F>
and flatMap
on the bottom one, whereas ap
calls map2
on the top one. This violates monad-applicative consistency laws. I am currently looking through cats source to see if they implement those methods any differentJannis
12/22/2019, 11:36 PMap
derived from Monad
which uses flatMap
. So this is specific to our code. I'd like to know the rationale behind the double kinds, might be because scats StateT
is actually IndexedStateT<F, S, S, A>
and it needs it somehow. Even their docs refer to StateT
as basically (S) -> Kind<F, Tuple2<S, A>>
. Anyway it's getting a bit late, so I'll think about it some more tomorrow...Jannis
12/22/2019, 11:42 PMJannis
12/22/2019, 11:47 PMState<S, A> == StateT<ForId, S, A>
where as this note describes that as faulty. Haven't used State
much on it's own so I don't know how stack safe it is, but I think we use AndThen
internally anyway. For now I'll change the ap
method to use flatMap
, remove all of the other applicative stuff that is explicitly implemented to get the laws passing...Jannis
12/23/2019, 12:02 AMStateT<ForId, S>
is definitly stacksafe according to our monad laws stack-safety test. So we probably don't need the double Kind<F, *>
, not gonna do too much to it either way, if it works, it works and using flatMap
for ap
is also fine anyway. 🤷simon.vergauwen
12/23/2019, 12:01 PMAndThen
was introduced for those stack-safety issues 🙂