Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
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
Soren
@srnb_gitlab
@tpolecat Promise me you'll find a monad transformer so we can get a PolecatT?
elyphas
@elyphas
@tpolecat ; really? is more easy?
Fabio Labella
@SystemFw
@elyphas just to be clear, you don't need any of this stuff to be proficient at pure FP
elyphas
@elyphas
@SystemFw , ah ok,
Rob Norris
@tpolecat
I'm kidding. Math is fun but you don't need to know any of this stuff.
But I do think the amount of category theory you can learn in an hour or two ends up being helpful to see some symmetries that otherwise wouldn't be apparent.
But I also think the marginal cost is very high once you get past chapter 1.
At least that's how it has worked out for me.
Fabio Labella
@SystemFw

being helpful to see some symmetries that otherwise wouldn't be apparent.

btw on this, CT can definitely be useful to see how two things you already understand actually relate to each other / are two examples of the same thing, but it's rarely what you want to tackle something you don't understand yet (at least in programming, at least at the typical level of proficiency in CT)

with the right explanations and by reading/writing code, you can understand and use ~all of pure FP without knowing any CT (though most people will pick up some of it almost by accident)
Rob Norris
@tpolecat
Agree with all of that.
Fabio Labella
@SystemFw
but definitely don't fall in the trap of thinking you need to digest a CT book to approach cats or cats-effect
elyphas
@elyphas
:)
thank you both,
Alex Henning Johannessen
@ahjohannessen
Is there some combinator for val a = F[Option[X]]; val b = F[Option[X]] that does a orElse b, now I do (a, b).mapN((a1, b1) => a1.orElse(b1)) - I guess it is something with traverse :D
Rob Norris
@tpolecat
You can do that with OptionT.
(OptionT(a) orElse OptionT(b)).value
You can say <+> instead of orElse, which is cooler. I mean, obviously.
Anton Sviridov
@keynmol
This is offtopic: does anyone here use quiver and/or know who maintains it? I want to publish it for 2.13 but not sure who to contact
Soren
@srnb_gitlab
Ooh! I just did graph stuff here a bit ago

https://gitter.im/typelevel/cats?at=5f64ae7df51808513b4fd4ab

@keynmol it seems https://github.com/getnelson/quiver is the fork you want, no clue who/how to contact tho

Anton Sviridov
@keynmol
ah ok, that's the one I fixed to work with 2.13
Soren
@srnb_gitlab
Honestly I think it'd be useful to create a cats-centric graph library but I'm not at all familiar with the part of graph theory that would say whether or not there's a GraphT monad transformer
And that'd probably be pretty important
Luka Jacobowitz
@LukaJCB
what would a graph monad’s behaviour be?
def flatMap[A, B](fa: Graph[A])(f: A => Graph[B]): Graph[B]
Anton Sviridov
@keynmol
A is probably not going to be the edge or node type, otherwise there's only so much you can do structurally to fit this signature