- Function composition
- Higher order functions
- Curry/Uncurry
- Referential transparency
- List (map, flatMap, filter, foldL, foldR)
- Option (map, flatMap, filter)
aahed | |
aalii | |
aargh | |
aarti | |
abaca | |
abaci | |
aback | |
abacs | |
abaft | |
abaka |
import scala.annotation.tailrec | |
sealed trait List[+A] | |
case object Nil extends List[Nothing] | |
case class Cons[+A](head: A, tail: List[A]) extends List[A] | |
object List { | |
def apply[A](as: A*): List[A] = | |
if (as.isEmpty) Nil |
Currently my implementation of code-gen from protobuf One-Ofs allows you to print valid Scala code from a proto file containing One-of (eithers/coproducts), but you cannot create a valid proto file back. Let’s say you have the following proto file
message Person {
string name = 1;
oneof avatar {
string image_url = 2;
Hi Muniverse, apologies for the delay, yesterday was our Seattle office party and I didn’t have as much time to try out the Traverse solution that Juan Pedro suggested. I’ve implemented a traverse function for ProtobufF and still run into the stack overflow error. (I also tried the @deriveTraverse
annotation, which is way cool! But it also resulted in the stack overflow.) I’m analyzing the difference between the code that Juan Pedro suggested in my minimal repro app and the actual code and 1 big thing sticks out as a problem.
In the Skeuomorph code, TRepeated is constructed with a value of type A. This makes sense, TRepeated should contain some type which repeats, which could be another Message or just a primitive type, like a String.
Here’s a loose representation of the structure we have:
`BaseDescriptor` ==========(Coalgebra)==========> `ProtobufF[A]`
// JSON AST | |
sealed trait JSON | |
case object JSNull extends JSON | |
case class JSString(get: String) extends JSON | |
case class JSNumber(get: Int) extends JSON | |
case class JSObject(get: Map[String, JSON]) extends JSON | |
final case class Person(name: String, email: String) | |
// Given any value, write it to JSON AST |