-
Notifications
You must be signed in to change notification settings - Fork 454
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
Typeclasses laws #112
Typeclasses laws #112
Conversation
raulraja
commented
Jun 15, 2017
•
edited
Loading
edited
- FunctorLaws
- ApplicativeLaws
- MonadLaws
- MonadErrorLaws (deferred to another PR since there is missing instances)
@@ -1,6 +1,6 @@ | |||
package katz | |||
|
|||
class EitherMonad<L> : Monad<EitherF<L>> { | |||
open class EitherMonad<L> : Monad<EitherF<L>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this class need to be open? Could it be an Interface instead?
@@ -3,14 +3,14 @@ package katz | |||
typealias KleisiTKind<F, A, B> = HK3<Kleisli.F, F, A, B> | |||
typealias KleisiF<F> = HK<Kleisli.F, F> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these two are misnamed too. Could you please use this diff to rename them to Kleisli?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some non blockers questions
|
||
object FunctorLaws { | ||
|
||
inline fun <reified F> laws(AP: Applicative<F> = applicative<F>()): List<Law> = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why use an Applicative here, if we are testing Functor laws here? should it be convenient use Functor instead of Applicative ins't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't create instances in the generator unless we create a specific typeclass for pure
or apply
since that is defined in Applicative and that is what we need to lift values into F[_]
M.flatMap(fa, { M.pure(it) }) == fa | ||
}) | ||
|
||
inline fun <reified F> kleisliLeftIdentity(M: Monad<F> = monad<F>()): Unit = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one question,
why in MonadLaws
have the particular case for Kleisli
Monad and not split into MonadLaws
and KleisliLaws
that have all the MonadLaws plus those 2 specific test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because Kleisli applies to all monads.
https://en.wikipedia.org/wiki/Kleisli_category
In category theory, a Kleisli category is a category naturally associated to any monad T. It is equivalent to the category of free T-algebras.
@kategory/maintainers I suggest we merge this now since master is already broken in many ways and this proofs some of the types that need immediate action |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll happily pass it, will work on the problems ASAP. I believe it may have to be rebased on master first, I'm not a fan of squashing.
* Suspend fx * Code review