Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Christopher Davenport
@ChristopherDavenport
Happy to discuss here in larger typelevel context, I do have a gitter channel where if youve been feeling this way for a long time we can discuss. The less things I have to maintain the more I will build.
Maintenance is the hard part overall.
Rob Norris
@tpolecat
Constant factors are pretty high. Keeping hello world up to date is a chore.
Gavin Bisesi
@Daenyth
^ seriously
Adam Rosien
@arosien
sponsors could pay folks to do it... i would take the $$$
michealhill
@micheal-hill
is there any name for the operation of transforming some A[B[*]] to a B[A[*]]? I seem to find myself needing to do this somewhat regularly...
Mark Tomko
@mtomko
sequence/traverse?
Adam Rosien
@arosien
:tada:
michealhill
@micheal-hill
awesome, thanks!
Mark Tomko
@mtomko
eg List(Some(1), Some(2), Some(3)).sequence yields Some(List(1, 2, 3))
and as noted recently, if you call map then sequence, you probably missed an opportunity to traverse
matrixbot
@matrixbot
cgntrn Is there a way to transform Algebra[F] => Algebra[G] if I have a function from F[A] to G[A]?
trait A[F[_]]
val aForList = new A[List]{}
def listToOption[A](l: List[A]) = l.headOption

val aForOption = ???
Rob Norris
@tpolecat
It's common to implement mapK[G[_]](fk: F ~> G): Alg[G]
Where F ~> G is an alias for FunctionK[F,G] which is a function from F[A] to G[A] for all A.
So you have to write it yourself but it's a common operation.
matrixbot
@matrixbot
cgntrn Would mapK be a function of the algebra?
Rob Norris
@tpolecat
Yes, or sometimes you can only define it for some F in which case you can add it with syntax.
Like if F needs to be a functor or something.
matrixbot
@matrixbot

cgntrn Sorry for taking so much of your time. I just have one more question.
Do I need to create a new algebra where I manually rewrite each function?
Such as:

abstract class A[F[_]: Applicative] {
    self =>
    def f(i: Int) = i.pure[F]
    def mapK[G[_]: Applicative](fk: F ~> G): A[G] = new A[G] {
      override def f(i: Int) = fk(self.f(i))
    }
  }

Is there a better way?

Adam Rosien
@arosien
that's the usual way, unless you use a library to autogenerate mapK for you.
matrixbot
@matrixbot
cgntrn I see. Thank you.
Soren
@srnb_gitlab
I can never remember which graph library I'm supposed to be using with Cats if I need DiHyperGraphs
(which is it?)
Gavin Bisesi
@Daenyth
I don't know about cats, but quiver (not the verizon/ repo, but the fork since that one is abandoned) has immutable graphs
Rob Norris
@tpolecat
quiver is an implementation of Erwig's inductive graphs, which is a cool paper https://web.engr.oregonstate.edu/~erwig/papers/InductiveGraphs_JFP01.pdf
Mark Tomko
@mtomko
that looks fun, thanks!
matrixbot
@matrixbot

cgntrn Is there any way to define an instance of an algebra for every subtype of a sealed trait and derive an instance of the topmost trait?
I'd like to define an algebra for L and R of

sealed trait TopMost                                                                                                    
class L extends TopMost                                                                                                 
class R extends TopMost

and freely derive that algebra for TopMost.

Is this possible?

Ethan
@esuntag
I think with a bit of mucking around you can get shapeless to do it
Do you want this generically, or just for a specific trait?
matrixbot
@matrixbot
cgntrn Just for one specific trait
Ethan
@esuntag
In that case probably best to just manually define it with a pattern match, unless it's there's enough subclasses that you want an automatic method
Ethan
@esuntag
Is there some sort of coFoldMapK or something? I was mucking about with a toy problem, and ended up with fa.coflatten.foldMapK(...)
Ethan
@esuntag
Also, I ended up in a situation with nested foldMapK. It's probably because I'm overengineering this, but is there something that might more succinctly express that?
Soren
@srnb_gitlab
I'm not familiar with comonads used generally, but maybe I can offer some help wrt the type signature? @esuntag
elyphas
@elyphas
I am sorry in advance, if this question is no proper in the channel.
but I feel curious about this statement.
"To properly credit the source for this idea, the perspective seems to be taken for granted in MacLane and Moerdijk's Sheaves in Geometry and Logic, which was where I was introduced to it.
The observation is the following: Categories are generalizations of monoids, and functors are the correct analog of representations."
this means Categories === Functors
?
Fabio Labella
@SystemFw
I think they mean that functors generalise representations and categories generalise monoids
elyphas
@elyphas
@SystemFw ; oh, thank you,
but representations in this case what would be?
Fabio Labella
@SystemFw
I can't say 100% for sure without seeing the source, but I think it refers to representation theory
for which the comparison with functors would make sense
elyphas
@elyphas
@SystemFw , thank you very much.
Fabio Labella
@SystemFw
a representation (in layman's terms) is a vector space that you map another structure to, and a functor is a mapping between categories
elyphas
@elyphas
ah ok
too much math, out of my hands at this moment. :)
I am reading about Yoneda lemma. and this crossed on my way,
@SystemFw , thank you! :)
Rob Norris
@tpolecat
too much math
Impossible