These are chat archives for typelevel/cats

5th
Jul 2016
Adelbert Chang
@adelbertc
Jul 05 2016 04:51
@tel i saw them - thanks for filing them! keep em coming :-)
Adelbert Chang
@adelbertc
Jul 05 2016 06:32
@tel i think @julien-truffaut experimented with a Scala profunctor lens impl a while back and ran into some issues, perhaps he can offer some guidance on what he ran into so you can keep an eye out
also im guessing you've seen Monocle
Julien Truffaut
@julien-truffaut
Jul 05 2016 06:53
@adelbertc correct, monocle used a profunctor impl a while ago. It works fine but the performance were really poor especially for get because the impl rely on several newtype wrapper having no cost at runtime in haskell
George Wilson
@gwils
Jul 05 2016 07:10
@julien-truffaut Can't we emulate that in Scala with Class Foo(x) extends AnyRefor something like that?
Adelbert Chang
@adelbertc
Jul 05 2016 07:15
@gwils i thought your name looked familiar. you give good talks :-)
i enjoyed your next level MTL talk
i think you're thinking of value classes, where you have something like case class Foo(x: Int) extends AnyVal which won't box if all you're doing is something like val f = Foo(5) but once you put it into something involving generics like List then you box because JVM (i think)
lemonxah
@lemonxah
Jul 05 2016 11:34
why have an Id Monad?
José Antonio Jiménez
@logistark
Jul 05 2016 12:02
umm, i dont know the true reason
but it is needed if you want to implement a Free Monad compiler
Alec Zorab
@AlecZorab
Jul 05 2016 12:03
it's useful for when you're writing code that abstracts over different monads. You can use it for very convenient testing, for instance
Joseph Abrahamson
@tel
Jul 05 2016 12:29
@adelbertc @julien-truffaut Ah, didn't realize it already went through an iteration in pure profunctor. I wanted to explore the API space in Scala... But if performance is already known to be terrible maybe it's not so worth it.
Julien Truffaut
@julien-truffaut
Jul 05 2016 12:56
@tel I am not an expert in performance, you might find a way to make it efficient.
I started a Lens benchmark a while ago for various impl, you might find it useful: https://github.com/julien-truffaut/LensImpl
Joseph Abrahamson
@tel
Jul 05 2016 12:57
Thanks, I’ll take a look!
I’m definitely not a performance expert either. I’m mostly just getting my feet wet looking at functional API design in Scala and where the limitations are.
But I could certainly see if there are any tricks to sneak some extra performance out of a lib like this
even the haskell lens library uses some unsafe coercions to actually get its performance at the end of the day… everything is supposed to just boil away, but GHC needs a little help
Julien Truffaut
@julien-truffaut
Jul 05 2016 13:05
I think it is an interesting exercice anyway but I find the attract of the profunctor based optics limited in scala because we cannot define optics as a type alias as it is done in haskell
Joseph Abrahamson
@tel
Jul 05 2016 13:35
I'm interested in writing down explicitly the contravariance of the profunctor ops constraint and the resulting lenses. That's been nice and I'm curious if it's gonna break soon.
Noel Welsh
@noelwelsh
Jul 05 2016 14:20
Anyone have ideas on how make IntelliJ work better with Cats? It highlights lots of bogus errors when using |@|, for example.
Merlin Göttlinger
@mgttlinger
Jul 05 2016 14:32
You could turn the error highlighting of and have a sbt session running to check for errors.
Alec Zorab
@AlecZorab
Jul 05 2016 14:33
yeah, I just go into power saving mode when I'm doing stuff intellij doesn't understand
Tomas Mikula
@TomasMikula
Jul 05 2016 17:23
@julien-truffaut @gwils @adelbertc @tel JVM will support user-defined value types (in generics, too) in version 10 (project Valhalla). Then I'm sure Scala will catch up to take advantage of them. That is still a long way to go, though (not even 9 is out yet).
Joseph Abrahamson
@tel
Jul 05 2016 17:24
very cool! although very far off :/
Julien Truffaut
@julien-truffaut
Jul 05 2016 17:56
maybe in 10 years ;)
felher
@felher
Jul 05 2016 19:33
Bands are semigroups whose operation (i.e. combine) is also idempotent.
I'm not sure what it means for a operation with two parameters to be idempotent? Does it mean combine(a, a) = combine(combine(a, a), combine(a, a))?
Hm, I didn't want the second line to be blockquoted. Oh well... :)
Or does it mean combine(a, a) = a?
Never mind, both are equivalent, now that I think about it :D
felher
@felher
Jul 05 2016 19:40
Oh, no there are not equivalent...
Tomas Mikula
@TomasMikula
Jul 05 2016 19:41
@felher the latter
felher
@felher
Jul 05 2016 19:41
@TomasMikula thanks :)
George Wilson
@gwils
Jul 05 2016 22:19
@lemonxah Id is important. It helps with monad transformers and with default instances for things. traverse in the Id Applicative is map
@adelbertc Thanks!
Adelbert Chang
@adelbertc
Jul 05 2016 22:23
its cool how these dumb data types let us do cool things like that
traverse with Const is fold \o/
George Wilson
@gwils
Jul 05 2016 22:23
Very cool :)
Conor McBride calls them "the functor kit".
Adelbert Chang
@adelbertc
Jul 05 2016 22:24
ah yes ive heard him use that term
there was another cool thing with lenses and Id and Const.. i think with Id modifyF is modify and Const with modifyF is set
Julien Truffaut
@julien-truffaut
Jul 05 2016 22:33
Const with modifyF is get
Adelbert Chang
@adelbertc
Jul 05 2016 23:47
ah yes