I hereby claim:
- I am neopryn on github.
- I am neopryn (https://keybase.io/neopryn) on keybase.
- I have a public key ASB2RR-fzWJ-5UPeSnZm0iQ85QK9-uvLfrRSXompgtthmQo
To claim this, I am signing this object:
type PNGExtension = { extensionType: "PNG", pngRelatedConfig: string } | |
type JPEGExtension = { extensionType: "JPEG", jpegRelatedConfig: string } | |
type LineArt = { artType: "lineart", polylines: string[] } | |
type Shapes = { artType: "shapes", shapes: Shape[] } | |
type Art = LineArt | Shapes | |
type Extension = PNGExtension | JPEGExtension | |
type RenderMetadata = Art & Extension |
type Square = { type: "square", edgeLength: number } | |
type Circle = { type: "circle", radius: number } | |
// Here's our Discriminant Union | |
type Shape = Square | Circle | |
function exhaustiveCheck(x: never): never { | |
throw new Error("Didn't expect to get here"); | |
} |
sealed trait Shape | |
object Shape { | |
case class Square(edgeLength: Int) extends Shape | |
case class Circle(radius: Int) extends Shape | |
} | |
def getShapeArea(shape: Shape): Double = shape match { | |
case Square(edge) => scala.math.pow(edge, 2) | |
case Circle(radius) => scala.math.Pi * radius * radius | |
} |
I hereby claim:
To claim this, I am signing this object: