Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Fabio Labella
@SystemFw
(although I'm half joking, I know the meaning you were using for that sentence)
Christopher Davenport
@ChristopherDavenport
I could see myself attempting it. Seems like a new paradigm to need to deal with as its even stricter than the semantics I’m thinking of. However it could be intriguing.
Feels a little like a stricter set of the dependently typed languages?
Fabio Labella
@SystemFw
most dependently typed languages are total languages
because you can't really use a nontotal language as a proof system
Agda is total, Idris has a total flag, and so on
Christopher Davenport
@ChristopherDavenport
Maybe I am daring enough. :laughing:
Christopher Davenport
@ChristopherDavenport
That being said, I appreciate languages with less strict guarantees that still give me the ability to build logical systems. I just have to build artificial walls at times to protect that system from things that are not guaranteed.
Jarred Ward
@jarreds
is there a function to Option[(A, B)] => (Option[A], Option[B])?
Andi Miller
@andimiller
separate
Christopher Davenport
@ChristopherDavenport
F[G[A, B]] => G[F[A], F[B]]
Jarred Ward
@jarreds
excellent, thank you both
Ryan Tomczik
@Tomczik76
Is there a reason there isn't a fish operator in cats?
Fabio Labella
@SystemFw
Not really. It's just a matter of finding where to put it, and a couple tricks to avoid breaking bincompat I think
you can wrap in Kleisli and use >>> though, for now
Ryan Tomczik
@Tomczik76
@SystemFw whats bincompact?
Also is there a difference between the *> and >> operators?
do they just come from different typeclasses but do the same thing?
Fabio Labella
@SystemFw
bincompat --> binary compatibility
I said >>>, not >>
but to answer your question
mostly yes
Ryan Tomczik
@Tomczik76
Yea, I know those were two different questions that have been rolling around in my head
Fabio Labella
@SystemFw
ah, right, sorry
I can give you more details on >> vs *> if you want
Dan Billings
@danbills
Is anybody out there generating Scala code from swagger/open api? Not seeing anything typelevel-y out there
Ryan Tomczik
@Tomczik76
@SystemFw yea I'd be interested to know
Fabio Labella
@SystemFw
are you familiar with mapN and flatMap?
Juan José Morales
@juanux
Hi guys. Could you help me with this ? I'm using 0.9.0 Cats version and I am trying to use "|@|" sysntax, but its not found anymore with this import import cats.implicits. catsSyntaxUCartesian .
Ryan Tomczik
@Tomczik76
Yes, flatmap from Monad and mapN from Applicative or Apply don't remember
Fabio Labella
@SystemFw
yep
so, definitions first
def *>[F[_]: Applicative, A, B](fa: F[A], fb: F[B]): F[B] = (fa, fb).mapN((_, b) => b)

def >>[F[_]: Monad, A, B](fa: F[A], fb: F[B]): F[B] = fa.flatMap(_ => fb)
does this make sense?
Ryan Tomczik
@Tomczik76
Yep, thats what I imagined the difference was
Fabio Labella
@SystemFw
right, are you also familiar with the Monad-Applicative consistency law?
Ryan Tomczik
@Tomczik76
Yes, I'm rarely defining them myself so it's not something that I do on a regular basis so I always have to reference them
Fabio Labella
@SystemFw
it just says that if a type F[_] is both an Applicative and a Monad, the two instances need to have the same behaviour
Ryan Tomczik
@Tomczik76
left/right identity, associativity, and one more I'm forgetting
Fabio Labella
@SystemFw
yeah, I'm not talking about those
I'm just talking about the one above
anyway, long story short
if you use a concrete type >> is the same as *> (with one caveat that I'll mention at the end)
if you use an abstract type with a Monad constraint, they are also the same
but with an Applicative bound they might not be
in code
def foo[F[_]: Monad] = fa >> fb //pseudocode actually
// is the same as
def foo[F[_]: Monad] = fa *> fb
// is _not_ necessarily the same as
def foo[F[_]: Applicative] = fa *> fb
because the third one could be instantiated with something that doesn't guarantee sequencing of effects, e.g. ParIO
the other caveat is when writing tail-recursive monadic functions