Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Luka Jacobowitz
@LukaJCB
You might be right :P I’m too tired right now
I’ve been looking at RWS e l s a for a couple of hours :D
Jakub Kozłowski
@kubukoz
hell yeah RWS
Adelbert Chang
@adelbertc
what, no T ?
Luka Jacobowitz
@LukaJCB
There’s a T there, but then you get m e l s a, which really isn’t as nice as elsa 🤷🏽‍♂️
Right now I’m trying to implement an Eq instance for RWST, which is kinda alright I guess
And of course right as I type this I realize there’s already one hidden in the cats test suite 🤦🏻‍♂️
Luka Jacobowitz
@LukaJCB
@adelbertc did you ever use the haskell layers package?
Man monad transformers are just one giant rabit hole that you’ll never actually get out of :smile: Why did the math gods not make them composable? :(
Adelbert Chang
@adelbertc
@LukaJCB nope, i just mtl my way through things
also i didnt know about that package until just now :)
Fabio Labella
@SystemFw
That's where cats mtl roughly comes from
Luka Jacobowitz
@LukaJCB
I’m a bit worried that the layers and monad-classes packages both seem pretty much abandoned in haskell land at this point
Fabio Labella
@SystemFw
well, the thing is that in Haskell mtl is pretty much the only game in town for final tagless given how ubiquitous it is
Ben Fradet
@BenFradet
I think I remember a mechanism to make string interpolation rely on show e.g. s"ab$c" would be equivalent to s"ab${c.show}"
does anyone know how or if I'm misremembering stuff?
Fabio Labella
@SystemFw
@BenFradet I think it's just show"things"
Luka Jacobowitz
@LukaJCB
show"ab$c"?
Too slow
Ben Fradet
@BenFradet
indeed thanks
Luka Jacobowitz
@LukaJCB
@SystemFw you think the reason it hasn't catched on is only to due to the ubiquitousness of mtl?
Fabio Labella
@SystemFw

you think the reason it hasn't catched on is only to due to the ubiquitousness of mtl

Well, I don't know for sure, but I'm sure that the weight of mtl is huuuge

removing MonadTrans in haskell is unthinkable
at least for the time being
Luka Jacobowitz
@LukaJCB
Yeah, that's true
In any case, I think we should do more to hide the various Layer type classes from cats-mtl users, probably said this before, but people have been asking me, and when I start explaining mtl and that they don't need to know about them, they usually realize mtl is fairly simple as a concept
Luka Jacobowitz
@LukaJCB
And by hiding them, I mean just adding more and better documentation 😁
Fabio Labella
@SystemFw
I agree
they should also not be in the top package actually
but in a lifting package
so instances hierarchy implicits syntax and lifting
leaving just the effect classes themselves at the top
Luka Jacobowitz
@LukaJCB
Yes agreed
Soren
@srnb_gitlab
I'm unable to call .traverse on a Vector[Json] using cats and circe. Extremely new to this style of programming and these libraries so I don't know what I'm doing wrong
  def transformObjectKeys(obj: JsonObject, f: String => String): JsonObject =
    JsonObject.fromIterable(
      obj.toList.map {
        case (k, v) => f(k) -> v
      }
    )
  def transformKeys(json: Json, f: String => String): Trampoline[Json] =
    json.arrayOrObject(
      Trampoline.done(json),
      _.traverse((j: Json) => Trampoline.defer(transformKeys(j, f))).map(Json.fromValues(_)),
      transformObjectKeys(_, f).traverse(obj => Trampoline.defer(transformKeys(obj, f))).map(Json.fromJsonObject)
    )
This is the code I'm attempting to use
Luka Jacobowitz
@LukaJCB
traverse doesn’t quite fit your bill, it has the following signature: F[G[A]] => G[F[A]], your Vector[Json] doesn’t fit, because Json does not take a type parameter
What is it you actually want to do?
ah okay, so you’re traversing with Trampoline[Json]
Andrew Valencik
@valencik
Is there existing work/literature I could poke around to learn about dealing with Tree structures that have lots of different sub types? In particular, SQL parse trees. A query can have many SelectItems and many Relations and eventually many Expression, but a Expression can also contain a query itself.
Jakub Kozłowski
@kubukoz
sounds a bit like fixed-point data types
from what I heard
Luka Jacobowitz
@LukaJCB
Recursion schemes
Jakub Kozłowski
@kubukoz
or that, yeah
Andrew Valencik
@valencik
Oh interesting. I know nothing about recursion schemes. I don't even know if "are they supported in cats?" is a reasonable question
Ghost
@ghost~55118a7f15522ed4b3ddbe95
you need multirec for that
object Fix2 {
  type Fix2_1[F1[_, _], F2[_, _]]
  type Fix2_2[F1[_, _], F2[_, _]]

  final class Subst[F1[_, _], F2[_, _]] {
    type Apply[H[_[_, _], _[_, _]]]  = H[F1, F2]
    type ApplyF[H[_, _]] = H[Apply[Fix2_1], Apply[Fix2_2]]

    def _1[H[_]](f: H[Apply[Fix2_1]]): H[ApplyF[F1]] = f.asInstanceOf[H[ApplyF[F1]]]
    def _2[H[_]](f: H[Apply[Fix2_2]]): H[ApplyF[F2]] = f.asInstanceOf[H[ApplyF[F2]]]
  }

  private[this] val _subst = new Subst[Any, Any]
  def subst[F1[_, _], F2[_, _]]: Subst[F1, F2] = _subst.asInstanceOf[Subst[F1, F2]]
}
I don't think it will be pleasant in Scala, but who knows
Andrew Valencik
@valencik
Shucks. So not much in the cats ecosystem then? I see matryoshka is decidedly scalaz again. Not sure how much that matters.