Arrow: Implement Bitraverse

Created on 2 Jun 2019  路  7Comments  路  Source: arrow-kt/arrow

Implement the Bitraverse interface in the arrow-core-typeclasses package as follows:

interface Bitraverse<F>: Bifoldable<F> {
  fun <G, A, B, C, D>  Kind<Kind<F<Kind<G, A>>, Kind<G, A>>>.bitraverse(AP: Applicative<G>, f: (A) -> Kind<G, C>, g: (B) -> Kind<G, D>): Kind<G, Kind<Kind<F, C>, D>>>

  fun <G, A, B> Kind<Kind<F<Kind<G, A>>, Kind<G, B>>>.bisequence(AP: Applicative<G>): Kind<G, Kind<Kind<F, A>, B>>> =
    bitraverse(::identity, ::identity)

 ...other necessary functions
}

See Bitraverse.scala for reference, and this tweet to see a visual use case.

The only law is Identity:

def <A, V> bitraverseIdentity(fab: Kind<Kind<F, A>, B>, ...) =
    fab.bitraverse(::identity, ::identity).equalsUnderTheLaw(fab, EQ)

Steps:

  • [ ] Define Interface
  • [ ] Add inline documentation to interface
  • [ ] Define Law
  • [ ] Add implementation for all instances of Bifoldable such as Tuple and Either
  • [ ] Make all the new instances be tested by BitraverseLaws
  • [ ] Add Bitraverse to Intro of Typeclasses below Bifoldable
  • [ ] Add Bitraverse page to the docs as a folder here. Use bifoldable as the baseline and modify it accordingly
help wanted

All 7 comments

Hi everyone, I am working on this issue, I have some of the points already and I am trying to have my first full implementation ready this week.
Regards

Brilliant! I'd suggest sending a Draft PR as early as possible so you can have some feedback just in case :D

sure, all the feedback I could have is welcome. I will send the PR as soon as I feel a little confident about it.

Guys I have implemented this in https://github.com/arrow-kt/arrow/pull/1487. Please review it and let me know of stuff you miss, errors or improvements.

@maruiz81 @pakoito #1487 got merged.
Is there something else to add or should we close this ticket?

yes, if you don't have any complaint I think we can close it.

Closing!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pakoito picture pakoito  路  3Comments

gortiz picture gortiz  路  3Comments

JLLeitschuh picture JLLeitschuh  路  4Comments

pakoito picture pakoito  路  4Comments

ovu picture ovu  路  4Comments