Skip to content

Conversation

@wennergr
Copy link
Contributor

  • Error handler for Read
  • Monadic combinators for Read
  • Constant constructor for Read
  • Verification of MonadError laws for Read

 * Error handler for Read
 * Monadic combinators for Read
 * Constant constructor
 * Verification of MonadError laws
@codecov
Copy link

codecov bot commented Jul 20, 2018

Codecov Report

Merging #11 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #11   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           7      7           
  Lines          99    126   +27     
  Branches        1      1           
=====================================
+ Hits           99    126   +27
Impacted Files Coverage Δ
src/main/scala/com/github/atais/util/Read.scala 100% <100%> (ø) ⬆️

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 89dc508...c1f6dbc. Read the comment docs.

@atais
Copy link
Owner

atais commented Jul 20, 2018

I was reading a book about cats recently and I have been thinking about adding those laws methods.
The thing that kept me back was, do I (we) need it here anyway ;-)?

@atais
Copy link
Owner

atais commented Jul 20, 2018

If you would rewrite Codec, Encoder and Decoder using that, I would say, at least it has some purpose.

I do not think End User would actually need to use (transform) Read monad at all.

@wennergr
Copy link
Contributor Author

wennergr commented Jul 23, 2018

Hey, thanks for your reply.

Can't really speak for you but I'm using them for sure!. It allows me to use the same pattern as with our JSON parser circe. Support for error handling seems like a good idea as well (and you can now write the or operator easily). The fact that these functions are lawful as well is delightful. (There is also a semigroupK instance in there). ;)

One trival example:

    // Functor (we often use wrapped value classes)
    case class UserId(repr: Long) extends AnyVal
    object UserId {
      implicit val read: Read[UserId] = longRead map UserId.apply
    }

I agree that the Encoder/Decoder vs Read/Write is a bit odd. The problem is a bit more complicated thou since you can't rely on the applicative (actually semigroupal) to load data into case classes. You will quickly hit the Scala 22 limit problem (Tuple22 and the mapN function on it). HList is the only solution to this (and it's a bit sad). We have one fixed with file with more then 200 columns.

I also care less about the flexibility of Encoder/Decoder as I don't need to intergrate with them much

I'm interested in hearing your future ideas with the library. I do have some ideas as well if you are interested. (not as part of the PR thou) ;)

Finally, Feel free to not go this path as well! It not a big deal for me to define these instances in my own code.

Cheers ;)

@atais
Copy link
Owner

atais commented Jul 30, 2018

Sorry about the delay, got busy with other tasks.

I like the overall idea, but I am wondering why didn't you extend Monad from cats in first place?

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.

2 participants