These are chat archives for typelevel/scala

16th
Nov 2017
Alexander Konovalov
@alexknvl
Nov 16 2017 19:39
A bug:
trait Foo[+A]
implicit def foo[A <: Singleton](implicit v: ValueOf[A]): Foo[A] = new Foo[A] { }
val s = ""
implicitly[ValueOf[s.type]] // works
implicitly[Foo[s.type]] // doesn't work
trait Foo[+A]
implicit def foo[A <: Singleton]: Foo[A] = new Foo[A] { }
val s = ""
implicitly[Foo[s.type]] // works
if Foo is invariant, implicit resolution works
It is specific to ValueOf[A]
trait Foo[+A]
trait Boo[A]
implicit def boo[A <: Singleton]: Boo[A] = new Boo[A] { }
implicit def foo[A <: Singleton](implicit v: Boo[A]): Foo[A] = new Foo[A] { }

val s = ""
implicitly[Foo[s.type]] // works fine
Edmund Noble
@edmundnoble
Nov 16 2017 19:43
@shimib_twitter If you want my honest thoughts as a random Scala FP user:
a) Comonads are incredibly underused in Scala mostly because of the lack of pervasive laziness
b) There are few useful comonads in the Scala FP ecosystem
c) The above factors make comonadic comprehensions' inclusion in LBS unlikely, making it unlikely that it will be included in TLS
Just my two cents
Though I may have misjudged the community
Also, there's a tendency not to allow new syntax in Scala 2, I believe
Guillaume Martres
@smarter
Nov 16 2017 19:46
Are comonads used in any language?
Edmund Noble
@edmundnoble
Nov 16 2017 19:46
Haskell has some use
Especially because of comonad transformers
We also have the disadvantage of bad type inference for comonad transformers in this area
Guillaume Martres
@smarter
Nov 16 2017 19:46
What do people do with them?
Edmund Noble
@edmundnoble
Nov 16 2017 19:47
Contextual computation, things with graphs, cellular automata, that kind of thing
Array computation
Zippers
You can also use the store comonad with lenses and that's a pretty nice formulation, scalaz lenses still do it that way and I've got some mileage out of that
Despite the other problems with scalaz optics
Guillaume Martres
@smarter
Nov 16 2017 19:48
Is there a library of common comonad transformers for Haskell ?
Edmund Noble
@edmundnoble
Nov 16 2017 19:48
Yeah
It's a shame people always pull out the NonEmptyList comonad because IMO that's a profoundly useless comonad compared to the rest