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
Fabio Labella
@SystemFw
you can also use MVar and Semaphore directly ofc
etienne
@crakjie
@SystemFw there is no Ref.update(f : A=F[A]) for exemple if I try to open a transaction closed? Maybe I should encode the error in the State?
oh modify is enought in fact to know what happen inside the update !
Ryan Peters
@sloshy
@crakjie In addition -- modify letting you sidestep the issue lets you concurrently reason about pure data better. The function you pass in can be ran potentially more than once due to the implementation not synchronizing access.
So if there were a variant that took a function to F[A] that would be potentially problematic
Gavin Bisesi
@Daenyth
This message was deleted
etienne
@crakjie
@rzeigler Could you explain what is a variant ?
etienne
@crakjie
@SystemFw I made that with your exemple https://gist.github.com/crakjie/7398a57124690f09a7e2037fc3112457 I still have to try it next week but I'm quite happy.
I was lucky that when looking for a state machine with Ref+ Deferred you actually already made one !
Ryan Zeigler
@rzeigler
@crakjie I think you mentioned the wrong person
etienne
@crakjie
Indeed sorry :x
Paulius Imbrasas
@CremboC
I just noticed, IO.redeem was never added to the typeclasses for cats 2.0?
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?