Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 05 2019 14:43
    @typelevel-bot banned @jdegoes
  • Jan 31 2019 21:17
    codecov-io commented #484
  • Jan 31 2019 21:08
    scala-steward opened #484
  • Jan 31 2019 18:19
    andywhite37 commented #189
  • Jan 31 2019 02:41
    kamilongus starred typelevel/cats-effect
  • Jan 30 2019 00:01
    codecov-io commented #483
  • Jan 29 2019 23:51
    deniszjukow opened #483
  • Jan 29 2019 23:37
  • Jan 29 2019 23:22
  • Jan 29 2019 20:26
    Rui-L starred typelevel/cats-effect
  • Jan 29 2019 18:01
    jdegoes commented #480
  • Jan 29 2019 17:04
    thomaav starred typelevel/cats-effect
  • Jan 28 2019 17:43
    asachdeva starred typelevel/cats-effect
  • Jan 28 2019 07:12
    alexandru commented #480
  • Jan 28 2019 05:45
    codecov-io commented #482
  • Jan 28 2019 05:35
    daron666 opened #482
  • Jan 27 2019 13:56
    codecov-io commented #481
  • Jan 27 2019 13:46
    lrodero opened #481
  • Jan 27 2019 05:47
    codecov-io commented #460
  • Jan 27 2019 05:37
    codecov-io commented #460
Rohde Fischer
@rfftrifork
@SystemFw heya, could I please have the link for your talk where you cover the niceness of referential transparancy? I got some colleagues who I think would appreciate it
(and if they don't too bad for them, I did appreciate it, so I'm gonna share it no matter if the do or don't xD )
Fabio Labella
@SystemFw
I don't have a talk specifically on that, but I do cover it in a few talks (shared state in pure FP, my fs2 talk at klarna), I do have a long reddit post on it though. If you browse through https://systemfw.org/talks and https://systemfw.org/writings you should find all the links you need
the reddit posts are called "the benefits of IO"
Rohde Fischer
@rfftrifork
@SystemFw ah ok, if I recall correctly you linked it when I specifically asked a lot of IO questions, but then it's a question of which one that triggered the linking
I think it's the one from Italy, so Shared State in Pure FP :) thanks, mate
Fabio Labella
@SystemFw
:+1:
Yury Ankudinov
@stremlenye
Hi. Does anybody knows by chance which cats-* library exposes the instance of Bracket for Either and if not what would be the reason?
Luka Jacobowitz
@LukaJCB
@stremlenye I’m curious, why would you need a Bracket instance for Either?
Yury Ankudinov
@stremlenye
@LukaJCB I am using Resource to acquire and cleanup dependencies for my IT tests. And unfortunately some of them synchronous.
Luka Jacobowitz
@LukaJCB
You should use SyncIO :)
Yury Ankudinov
@stremlenye
Think of the result they give as Either[Throwable, Assertion]
@LukaJCB I do, but in more up-to-date ones :)
Luka Jacobowitz
@LukaJCB
I don’t think Either is a great replacement for SyncIO
Yury Ankudinov
@stremlenye
It's vice versa. We are slowly replacing Either. It's just it still a lot of the tests still implemented in an old way.
Luka Jacobowitz
@LukaJCB
That’s fair :) I think you
you’re best of just writing your own Bracket instance
Yury Ankudinov
@stremlenye
Already done. Just was curious how comes there were none :)
Anyways thank you.
Daniel Spiewak
@djspiewak
there definitely could be one
in fact there could be a Bracket for any MonadError
getting the prioritization right would be tricky though
Yury Ankudinov
@stremlenye
@djspiewak Indeed. I'll take a look if I could make it this way.
Daniel Spiewak
@djspiewak
I'd be interested to see what you come up with!
Michael Pilquist
@mpilquist
(ResourceProxy stuff we’ve discussed a few times)
underscore05
@underscore05
I would like to seek help refactoring this code. I don't know if should wrap the ValidatedNec to IO or what... I also wanted to have a logger on every validation.
type ValidationResult[A] = ValidatedNec[JobPostError, A]

override def createJobPost(
    newJobPost: JobPost
): IO[ValidatedNec[String, JobPost]] = {
  // TODO: Add logger here on every field validation
  val localValidation: ValidationResult[JobPost] = (
    validateNoop(newJobPost.id),
    validateEmptiness("Job post title".some, newJobPost.title),
    validateEmptiness("Job post description".some,
                      newJobPost.description),
    validateNoop(newJobPost.createdAt),
    validateNoop(newJobPost.modifiedAt)
  ).mapN(JobPost)

  val databaseValidations: IO[ValidationResult[JobPost]] = (for {
    _ <- Logger[ConnectionIO].info("Validating job title")
    title <- validateTitleExistence(newJobPost)
    _ <- Logger[ConnectionIO].info("Validating job description")
    description <- validateNoop(newJobPost.description).pure[ConnectionIO]
    createdAt <- validateNoop(newJobPost.createdAt).pure[ConnectionIO]
    modifiedAt <- validateNoop(newJobPost.modifiedAt).pure[ConnectionIO]
    id <- validateNoop(newJobPost.id).pure[ConnectionIO]
  } yield {
    (id, title, description, createdAt, modifiedAt).mapN(JobPost)
  }).transact(xa)

  val response: IO[ValidatedNec[String, JobPost]] =
    localValidation match {
      case Valid(_) => databaseValidations.map(_.leftMap(_.map(_.errorMessage)))
      case Invalid(e) => e.map(_.errorMessage).invalid[JobPost].pure[IO]
    }
  response
}
Oleg Pyzhcov
@oleg-py
@underscore05 is noop always valid, and is it temporary or there to stay?
underscore05
@underscore05
@oleg-py this one is just temporary since I don't have validation rules for them yet.
Or is there much better way to do this in case that I just want to validate some of the case class fields?
Oleg Pyzhcov
@oleg-py
Yeah, you just... don't check them. And if you don't alter the value, you don't need mapN either:
val localValidation = validateEmptiness(...) *> validateEmptiness(...) *> newJobPost.validNec
actually you never use the Valid case in your result, so you don't even need the last clause
Oleg Pyzhcov
@oleg-py
For doing DB validations, it really depends on how much you need to query and how soon do you want to stop.
underscore05
@underscore05
@oleg-py in my case will it execute all query before performing validation on the yield part?
Oleg Pyzhcov
@oleg-py
Yes, and if you have just one query, you'd probably be better off ditching for-comprehension
underscore05
@underscore05
Ok man, thank you
Paul Snively
@paul-snively
Also, consider some sort of Merge typeclass for updating a value with defaults.
Luka Jacobowitz
@LukaJCB
Merge? Is that just a less fancy way of saying Semilattice?
Or Band
Gavin Bisesi
@Daenyth
Is there any sort of stance on adding "duplicate" methods in more discoverable locations? An example I'm thinking of is adding IO.parSequence or parSequenceN. It's not immediately obvious where that behavior lives if you're using IO directly and not the typeclasses. Even with the typeclasses, parSequence and parSequenceN for example exist in different typeclasses, and it's not necessarily obvious to a newcomer why that might be
I'm writing some aimed-at-beginners info around IO and some cases like that make things less discoverable than I'd want it to be
Other examples might be typeclass methods/syntax on IO as direct methods; things like >> or adaptError
The "tax" of needing the cats.implicits._ import in order to get the "full" API for IO is a little unfortunate I think
It's not wrong, which is why I ask if there's a stance on it, or if it's just been organic and ad-hoc as to which things get added where
Paul Snively
@paul-snively
@LukaJCB: I took the point of the suggestion at the link to be that it's easy to provide a typeclass and automatic derivation of it for types Shapeless can automatically derive it for, but I have to confess to not being familiar enough with Semilattice or Band to comment.
@LukaJCB: Other than perhaps to observe that I've seen some papers saying "Hey, CRDTs are bounded semilattices!" But few to no Scala CRDT libraries reflecting that, or uses of Semilattice or Band, for that matter.
Gavin Bisesi
@Daenyth
Does anyone have an example of code that deadlocks with unsafeRunSync() given a single thread but works with unsafeToFuture()?
Does that even make sense?
Paul Snively
@paul-snively
@LukaJCB: To be very frank, over the last few years, I've been... underwhelmed... by the state of Scala's ecosystem around a really sophisticated understanding of data, in the sense of, e.g. https://www.cs.indiana.edu/~dgerman/2008midwestNKSconference/tarau_paper.pdf