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
So abstract over variance
Felix Mulder
@felixmulder
T_T
that sounds super hairy
Fabio Labella
@SystemFw
I don't know if the same holds for Monaderror though
Felix Mulder
@felixmulder
What do you think the risk is of making MonadError / ApplicativeError contravariant in E?
Fabio Labella
@SystemFw
Just that there were experiments with typeclasses and variance in the early days of scalaz, and they ended up with scrapping variance from data types as well :joy:
I can't reason about variance like that without pen paper and time
But you should definitely try it out and see
The underlying monad error problem is super important IMHO
Felix Mulder
@felixmulder
I'll just go to twitter and tag people -- maybe someone remembers
:+1:
I'll be the battering ram
Rob Norris
@tpolecat
Stephen Compall (S11001001) is the person to talk to. He has thought more about variance than anyone else over there I think.
The big problem was with things like trait Functor[F[+_]]
Felix Mulder
@felixmulder
@tpolecat - thanks Rob, I'll try to get a hold of him!
Emily Pillmore
@emilypi
hola, hombres
Rob Norris
@tpolecat
hi
Luka Jacobowitz
@LukaJCB
Hola!
Oleg Pyzhcov
@oleg-py
@felixmulder I'm actually working on a library that among other things lets you derive MonadError[F, E] given MonadError[F, Throwable] and E <: Throwable :smile:
Fabio Labella
@SystemFw
@oleg-py heh, wanted to mention mews but wasn't sure if you had tackled MonadErroryet
Oleg Pyzhcov
@oleg-py
I'm actually getting close to first release, just need to add more tests and law-checks :smile:
Fabio Labella
@SystemFw
nice
long term it should be in cats-mtl if it works out, you know what I think :)
Oleg Pyzhcov
@oleg-py
I've also added stuff from cats-effect so I can get rid of some StateTs :smile:
Felix Mulder
@felixmulder
@oleg-py -- cool! Gonna have a look at what you've been up to :)
Luka Jacobowitz
@LukaJCB
We need to overhaul the cats-mtl docs, I think most people are really confused by things like MonadLayerControl, when they don’t even need it at all, and should only use ApplicativeAsk, MonadState et al
Yuriy Badalyantc
@LMnet
Hi! Why cats contains Order typeclass when we have Ordering in the standart library?
felher
@felher
Hey folks. In the introductionary FP course I'm giving we are currently working our way through monads. The theoretical groundwork has been done ( operations and laws ) and it's time to go through a few monads as examples and see how and when to use them. They have already seen Option,Either, and State (and, kind of, List). I'd like to do three more examples. What monads would you suggest? Currently I'm thinking about Reader and Writer.
Andi Miller
@andimiller
I'd probably go for Eval or IO
Fabio Labella
@SystemFw
@felher Reader is not super interesting (ReaderT/Kleisli is, but that's a transformer), but I'd do it anyway . I'd go for List a bit more (behaves "weirdly" which is good to break false assumptions, and prepares you for fs2.Stream), and more importantly IO
however IO requires some subtlety when teaching it, so you might want to make sure they know how to write code with algebras first
and by that I mean code that doesn't use any specific details of the datatypes they're using, but only the algebras defined for them
for example, write code on State without using s => (a, s), but only the combinators
the reason for that is that you want them to get used to IO as an opaque entity imho
Fabio Labella
@SystemFw
I have other examples but it kinda depends on whether you want to focus on how to use monadic abstractions, or how to implement them. Most literature focuses on implementing them on one hand, or in "real world examples" without much explanations on the other, whereas I think developing the sort of thinking that lets you write code using algebras only is very important, and not necessarily always explained well.
Emily Pillmore
@emilypi
@SystemFw Ed just came up with an interesting use for Reader using classy lenses. It's really cool ;)
Oleg Pyzhcov
@oleg-py
@emilypi link? :)
felher
@felher
I think IO/Eval might be a bit too hard just now. Most of them have never done any functional programming until a few weeks ago and now have only had 6 or so lectures to take it in. My goal is to provide a 'intermediate' FP lecture next semester in which IO/Eval would be taught.
@SystemFw could you give an example of what you mean when you say List behaves weirdly?
Fabio Labella
@SystemFw
@emilypi link?
@felher yeah, in that case fair enough
well, weirdly was in quotes
but one example would be the intuition that *> means "and then"

State , check
IO, check

Ok the intuition holds...

List(1,2,3) *> List(4, 5, 6) <--- intuition breaks
again, fs2.Stream behaves like List in many respects so this is a good exercise regardless
felher
@felher
Oh, that's a great example!
Fabio Labella
@SystemFw
the instances for (-> a) (Reader) are also useful for breaking wrong intuitions / expanding one's mind, but they work better in Haskell
Emily Pillmore
@emilypi
@SystemFw when the Lambdaconf vids come out, look for it. I don’t think he’s posted slides, but you could ask him
it was effectively managing logging states using reader + pprism and plens
as opposed to the usual StateT-type solution