-
Notifications
You must be signed in to change notification settings - Fork 709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Monad transformers switch type #1800
Conversation
Yes, the latter. (I wouldn't follow Haskell religiously, but it cannot hurt to check what has worked there: The RWST monad transformer.)
I would say yes, if only for consistency.
This should go away after it is changed to
I would change method type parameter order accordingly, but I don't think it would apply to these examples. We should also remove the following from CONTRIBUTING.md:
|
Should this not necessarily be removed entirely but just simply changed to say something else. For example, we could change it to read "The higher-kinded type (i.e. def method0[F](fa: F[_]): F[_] = ???
def method1[F, A](fa: F[A]): F[A] = ???
def method2[F, A, G, B](fa: F[A], f: A => G[B]): G[B] = ???
case class Clazz0[F[_]]
case class Clazz1[F[_], A]
case class Clazz2[F[_], A, G[_]] I'm asking partly because I do not fully understand yet what is gained by switching these type parameters, nor what problems might arise with the above examples I'll address your other comments later. Hopefully by the end of the day. |
It is just optimizing for the most common use case in conjunction with partial unification. It's just more common in practice that one needs to infer val foo: StateT[S, F, A] = ???
def bar[MT[_[_], _], G[_], B](mtgb: MT[G, B]): Unit = ???
bar(foo) // trying to unify MT[G, B] with StateT[S, F, A],
// B is unified with A, G is unified with F,
// and MT is unified with StateT[S, ?[_], ?] |
Thanks. I also read through scala/scala#5102 and that explained a bit more context, too. |
3708907
to
fae51dd
Compare
For ContT's type alias hierarchy... // changes to ContT[R, Id, A]
type Cont[R, A] = ContT[Id, R, A]
// does this change to ContsT[R, Id, M, A] ???
type ContT[M[_], R, A] = ContsT[Id, M, R, A]
// Does this change to IndexedContsT[R, W, M, R, A] ???
type ContsT[W[_], M[_], R, A] = IndexedContsT[W, M, R, R, A] |
Note: the current code does not make the corresponding swap in the test package. I'll need to update it for that, too. |
As in other monad transformers, make the second to last type parameter be the monad As for the comonad type parameter |
Looks like I'll need to fix |
Oh, nvm. I did it correctly the first time. |
In implicit def endoEqual[F[_], G[_[_], _, _], A](
implicit F: Equal[G[F, A, A]]
): Equal[Endomorphic[G[F, ?, ?], A]] =
Equal.equalBy(_.run)
checkAll(monoid.laws[Endomorphic[Kleisli[?, Option, ?], Int]])
checkAll(semigroup.laws[Endomorphic[Cokleisli[Option, ?, ?], Int]]) It fails at |
|
ac9cc0e
to
487cd9d
Compare
I suggest to leave type ReaderT[A, F[_], B] = Kleisli[F, A, B] If that causes problems, leave out It is in fact the case that when we talk about On the other hand, when we use the This is also how things are in Haskell (Kleisli, ReaderT): Kleisli m a b
ReaderT r m a |
Alright, I'll try that out and see how it goes. Also, I'm still not sure why
|
18fdbf3
to
80b8307
Compare
I'll push the EitherT type swap commit (cherrypick) once I see how this does since it is known that the EitherT commit has compilation issues. |
Aye. The code compiles, but some test is looping infinitely and causing the build to time out. |
I've done my part. Now I need help from the community:
|
@JordanMartinez |
So... The last comment that implies this should be done for the |
@JordanMartinez Thanks for making it this far! Folks will chime in as they have time, and I'll do a review of the type parameter ordering when I get a chance. |
@JordanMartinez The order looks correct to me! I did not check that all type classes were so modified, but the ones in this pull request look good. 👍 |
@jdegoes Thanks for the feedback! I looked into the tests not responding and have narrowed the problem down to the StateT commit. When I tested that commit, the tests stopped responding just like the build here. So, I cherrypicked the WriterT commit on top of the HEAD of the I'm looking into why the EitherT example isn't compiling next. |
The problem with However, we can instruct the compiler to consider this possibility by adding a new case of implicit def unapplyMAFB[TC[_[_, _]], M0[_, _[_], _], A0, F0[_], B0](implicit TC0: TC[M0[?, F0, ?]]): Unapply2[TC, M0[A0, F0, B0]] {
type M[X, Y] = M0[X, F0, Y]
type A = A0
type B = B0
} =
new Unapply2[TC, M0[A0, F0, B0]] {
type M[X, Y] = M0[X, F0, Y]
type A = A0
type B = B0
def TC = TC0
def leibniz = refl
} |
I can't get to this now, but hopefully will before the end of today. Thanks for the explanation @TomasMikula! |
(cherry picked from Tomas Mikula - commit 23cbe16)
5b0bd52
to
719294d
Compare
If this PR is merged now, the |
Or just open a PR removing it and discuss there. |
See #1841. |
Don't merge this yet. Similar to the |
After checking this again, only the Abritraries of |
6d72971
to
2ae4005
Compare
Not sure whether this is waiting for other members' approval, or the core contributors are just busy, or it is believed that this PR isn't ready for merging due to my prior comment. So, just to clarify, the final issue has been resolved and I believe this is ready for merging/review from others (if that's what's needed). |
@jonm Looks good! Thank you Jordan! |
Addresses #1305
Note:
F[_]
should go in the type signature (e.g.RWST[R, F, W, S, A]
orRWST[R, W, S, F, A]
? I'm assuming the latter...?)IndexedStateT
)StateT[S, F, A]
would not compile unless type was changed to that which it aliases:IndexedStateT[F, S, S, A]
method[F[_], A]
stays the same? or becomesmethod[A, F[_]]
? /MonadPlus[F[_], A]
orMonadPlus[A, F[_]]
)I'm going to sleep after this, so won't respond until Monday.