-
Notifications
You must be signed in to change notification settings - Fork 449
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
Syntax for all typeclass targets, values and datatypes #132
Conversation
Codecov Report
@@ Coverage Diff @@
## master #132 +/- ##
=========================================
Coverage ? 51.98%
Complexity ? 160
=========================================
Files ? 66
Lines ? 1458
Branches ? 175
=========================================
Hits ? 758
Misses ? 629
Partials ? 71
Continue to review full report at Codecov.
|
* | ||
* Note: will not terminate for infinite-sized collections. | ||
*/ | ||
fun <A> size(ml: Monoid<Long>, fa: HK<F, A>): Long = |
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.
What happened to size?
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.
It does not work for all collections and was not used elsewhere. We should not have unsound APIs. I believe if we want to allow size
like defined here it should be moved to a Typeclass Sizeable
that finite collections and data types like List
and NonEmptyList
can provide instances for.
@@ -11,5 +11,11 @@ interface MonadReader<F, D> : Monad<F> { | |||
fun <A> reader(f: (D) -> A): HK<F, A> = map(ask(), f) | |||
} | |||
|
|||
inline fun <reified F, A, reified D> HK<F, A>.local(FT: MonadReader<F, D> = monadReader(), noinline f: (D) -> D): HK<F, A> = |
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.
Can you call local with syntactic sugar, and still get the default?
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.
Not sure I get what you mean by the default
. Can you please clarify? thanks!
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.
Assuming Option has a monadReader, could you call 1.some().local { it }
? I thought defaults only worked if they were the last parameters.
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.
Yes, that compiles though it fails at runtime because Option has no MonadReader instance which is one of the challenges we face because our instance lookups are at runtime since Kotlin lacks implicits or any proper support for typeclasses.
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'm on it, I'm on it. Soon :D
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.
Looks really good to me. Brilliant that we can instantiate most types from anywhere. The touch of ext fun for flatMap is a great idea too, it should be applied to the other typeclasses too.
IntelliJ's suggestions will not like it as much hahaha
* 0.11.0/bio (#1975) * BIO - Part 1 (#1851) * Add E param * Fix imports & types * Add RaiseError case * Refactor IO name * [BIO]: include `E` into IOFrame & IORunLoop (#1859) * Rewrite IOFrame * Update IORunLoop & fix resulting combinators * Move public code to IO.kt * Refactor Right to Success * IO: IOConnection & IOBracket (#1870) * Update ForwardCancelable * Update IOBracket * Remove KindConnection and refactor into IOConnection * IO Concurrency combinators & Green Build (#1892) * BIO - Part 1 (#1851) * Add E param * Fix imports & types * Add RaiseError case * Refactor IO name * [BIO]: include `E` into IOFrame & IORunLoop (#1859) * Rewrite IOFrame * Update IORunLoop & fix resulting combinators * Move public code to IO.kt * Refactor Right to Success * IO: IOConnection & IOBracket (#1870) * Update ForwardCancelable * Update IOBracket * Remove KindConnection and refactor into IOConnection * Rewrite UnsafePromise * Rewrite ParMap2 * Update IOParMap3 * Update IORacePair * Update IORaceTriple * Fix tests * Fix KIO benchmarks * Fix imports Ank * Fix IOExample * Fix unused imports * Fix imports benchmarks * Fix arrow-integrations-retrofit-adapter * Fix FpToTheMax & typeclasses example * KtLintFormat * Fix IOTest * Fix more tests * Fix merge conflicts * KtLintFormat * Fix MaybeK bracket and use it for QueueTest * Throw proper exception in impossible cases * Revert removing runAsync * Fix build * KtLintFormat * Temporary solution for DSL receiver conflict overloads (#1994) * Add fix and test (#2013) * More meaningful functions mapping Either to BIO (#2002) (#2003) * Add missing test and fix merge review changes (#2016) * Change cancel wording to have 2 Ls for consistency (#2055) * Arrow test conflict after merge * Fix benchmarks * Fix build * Fix some errors in tests and code Fix L spelling of cancellable * Conf: separate 0.11.0 version * Merge fixes * Merge fixes * Fix package for eq (#135) * Fix doc generation and validation failures (#132) Co-authored-by: nomisRev <vergauwen.simon@gmail.com> Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com> * After release 0.10.5: just considering one wip version (#133) Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com> Co-authored-by: Simon Vergauwen <vergauwen.simon@gmail.com> Co-authored-by: Paco <pakoito@users.noreply.github.com> Co-authored-by: Oskar Drozda <themppsplx@gmail.com> Co-authored-by: Alberto Ballano <aballano@users.noreply.github.com> Co-authored-by: raulraja <raulraja@users.noreply.github.com>
No description provided.