Welcome! Got a question? Do you have -Ypartial-unification turned on? Other FAQs: http://typelevel.org/cats/faq.html
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)
underscored_keys
into camelCasedKeys
and back
implicit val config: Configuration = Configuration.default.withSnakeCaseMemberNames
with semiauto
decoding/encoding should work
Configuration
with a custom key renaming strategy. Probably better than manually traversing the jsons
val keyCorrectionReg: Regex = """_([a-z])""".r
val keyDeCorrectionReg: Regex = """([A-Z])""".r
implicit val config: Configuration = Configuration.default.withSnakeCaseMemberNames.copy(transformMemberNames = s => {
keyDeCorrectionReg.replaceAllIn(s, m => "_" + m.group(1).toLowerCase)
})
keyCorrectionReg
isn't used in this
r.e. recursion schemes -- I'm creating the corresponding NodeF[A]
for my Node
type, but what's the right way to generalize something like
sealed trait Node
final case class Name(value: String) extends Node
sealed trait Expression extends Node
final case class Block(name: Name, exprs: List[Expression]) extends Node
where I want to keep the more narrow type for some values? because I currently have
sealed trait NodeF[A]
final case class NameF(value: String) extends NodeF[A]
sealed trait ExpressionF[A] extends NodeF[A]
final case class BlockF[A](name: A, exprs: List[A]) extends NodeF[A]