-
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
Add implementation of WriterT and WriterTMonad #85
Conversation
Missing: tests. Do not merge yet. |
…ption. Add Semigroup instances for NonEmptyList and Number. Add tests for WriterT. Add tests for NumberSemiGroup, OptionMonoid, and NonEmptyListSemiGroup.
I went overboard and fixed the Monoid and Semigroup instances. |
|
||
class NonEmptyListSemigroup<A> : Semigroup<NonEmptyList<A>> { | ||
override fun combine(a: NonEmptyList<A>, b: NonEmptyList<A>): NonEmptyList<A> = | ||
NonEmptyList.fromListUnsafe(a.all + b.all) |
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.
This is the same as just a + b
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.
No, the compiler won't pick it up for whatever reason :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.
Committed a fix :)
…rly used as they were. Disabled detekt removing Unit return types since it caused the build to fail. Re-applied detekt and fixed formatting.
Codecov Report
@@ Coverage Diff @@
## master #85 +/- ##
=========================================
Coverage ? 43.35%
Complexity ? 104
=========================================
Files ? 51
Lines ? 775
Branches ? 130
=========================================
Hits ? 336
Misses ? 391
Partials ? 48
Continue to review full report at Codecov.
|
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 should add also MonadWriter
and the rest of the MTL style popular typeclasses
@@ -20,7 +20,9 @@ interface Applicative<F> : Functor<F>, Typeclass { | |||
fb.map { fb -> map2(fa, fb, f) } | |||
} | |||
|
|||
data class Tuple2<out A, out B>(val a: A, val b: B) | |||
data class Tuple2<out A, out B>(val a: A, val b: B) { | |||
fun swap(): Tuple2<B, A> = Tuple2(b, 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.
what if we call this reverse
and implement it in all Tuple*?
@@ -30,6 +32,10 @@ data class Tuple8<out A, out B, out C, out D, out E, out F, out G, out H>(val a: | |||
data class Tuple9<out A, out B, out C, out D, out E, out F, out G, out H, out I>(val a: A, val b: B, val c: C, val d: D, val e: E, val f: F, val g: G, val h: H, val i: I) | |||
data class Tuple10<out A, out B, out C, out D, out E, out F, out G, out H, out I, out J>(val a: A, val b: B, val c: C, val d: D, val e: E, val f: F, val g: G, val h: H, val i: I, val j: J) | |||
|
|||
infix fun <A, B, C, D> Tuple3<A, B, C>.toT(d: D): Tuple4<A, B, C, D> = Tuple4(this.a, this.b, this.c, 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.
Should this be plus
? Also wondering what a Semigroup
instance for each of the tuples looks like ;)
* arrow-kt#85: Add Enum encoder and decoder * arrow-kt#85: Add Enum test * arrow-kt#85: Add negative tests for enum decoder * arrow-kt#85: Clean up test names and move the enum code to the correct package * move enum instances to its companion object * arrow-kt#85: Add enum section to docs * arrow-kt#85: Docs formatting * arrow-kt#85: Combine enum docs fragments * arrow-kt#85: Import helios.instances.* * arrow-kt#85: Silence Ank * arrow-kt#85: Split up section on Enum * arrow-kt#85: Fix Enum decoder return type * Update docs/docs/coding/README.md Co-Authored-By: Adrian Ramirez Fornell <[email protected]>
* Deprecate extension methods for NonEmptyList * Move NonEmptyList top-level functions to Lens companion * Update tests * Update deprecation message
Closes #84