Welcome! Got a question? Do you have -Ypartial-unification turned on? Other FAQs: http://typelevel.org/cats/faq.html
MonadTrans
in haskell is unthinkable
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
lifting
package
instances
hierarchy
implicits
syntax
and lifting
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
Trampoline[Json]
SelectItem
s and many Relation
s and eventually many Expression
, but a Expression
can also contain a query itself.
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]]
}
queries
have expressions
and expressions
have expressions
and queries
makes this a type with multiple mutually recursive types? And furthermore, matryoshka does not support multiple mutually recursive types, but multirec does?
final case class Query(e: Expr)
final case class Expr(e: Query)
// this will work with matryoshka
// can recurse only over one part at a time
final case class QueryF[Q](e: Expr[Q])
final case class Expr[Q](e: Q)
// this requires something like multirec
final case class QueryF[Q, E](e: E)
final case class ExprF[Q, E](e: Q)