Skip to content
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

Merged
merged 3 commits into from
Jul 19, 2017

Conversation

raulraja
Copy link
Member

No description provided.

@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@f3f5836). Click here to learn what that means.
The diff coverage is 2.22%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #132   +/-   ##
=========================================
  Coverage          ?   51.98%           
  Complexity        ?      160           
=========================================
  Files             ?       66           
  Lines             ?     1458           
  Branches          ?      175           
=========================================
  Hits              ?      758           
  Misses            ?      629           
  Partials          ?       71
Impacted Files Coverage Δ Complexity Δ
kategory/src/main/kotlin/kategory/data/Option.kt 43.75% <ø> (ø) 2 <0> (?)
kategory/src/main/kotlin/kategory/data/Try.kt 57.5% <ø> (ø) 4 <0> (?)
kategory/src/main/kotlin/kategory/arrow/Kleisli.kt 55.55% <ø> (ø) 8 <0> (?)
...ategory/src/main/kotlin/kategory/typeclasses/Eq.kt 50% <ø> (ø) 0 <0> (?)
kategory/src/main/kotlin/kategory/data/Ior.kt 37.97% <ø> (ø) 16 <0> (?)
...gory/src/main/kotlin/kategory/data/NonEmptyList.kt 57.57% <ø> (ø) 16 <0> (?)
kategory/src/main/kotlin/kategory/effects/IO.kt 55.78% <ø> (ø) 7 <0> (?)
kategory/src/main/kotlin/kategory/data/State.kt 100% <ø> (ø) 2 <0> (?)
...ory/src/main/kotlin/kategory/typeclasses/Inject.kt 0% <ø> (ø) 0 <0> (?)
kategory/src/main/kotlin/kategory/free/Free.kt 59.45% <ø> (ø) 1 <0> (?)
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f3f5836...338a608. Read the comment docs.

*
* Note: will not terminate for infinite-sized collections.
*/
fun <A> size(ml: Monoid<Long>, fa: HK<F, A>): Long =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened to size?

Copy link
Member Author

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> =
Copy link
Member

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?

Copy link
Member Author

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!

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member

@pakoito pakoito left a 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

@ffgiraldez ffgiraldez merged commit aaf4192 into master Jul 19, 2017
@ffgiraldez ffgiraldez deleted the rr-hk-syntax branch July 19, 2017 20:56
rachelcarmena added a commit that referenced this pull request Feb 24, 2021
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants