Skip to content

Instantly share code, notes, and snippets.

@lombardo-chcg
lombardo-chcg / functor-hierarchy.scala
Last active November 10, 2021 01:59
functor hierarchy
import scala.language.higherKinds
object Example {
// demo version of the Option type for example use
sealed trait Maybe[+A]
case class Just[+A](value: A) extends Maybe[A]
case object Niente extends Maybe[Nothing]
trait Functor[F[A]] {
/*
Ammonite script
http://ammonite.io
*/
import $ivy.{
`org.json4s:json4s-ext_2.12:3.5.0`,
`org.json4s:json4s-jackson_2.12:3.5.0`,
`org.json4s:json4s-native_2.12:3.5.0`,
`org.scalaj:scalaj-http_2.12:2.3.0`,
@lombardo-chcg
lombardo-chcg / RandomData.scala
Created February 23, 2019 00:55
a shapeless-powered type class to generate random case class instances
// ammonite import
import $ivy.`com.chuusai:shapeless_2.12:2.3.3`
import shapeless.{Generic, ::, HList, HNil}
// part 1: define the type class
trait RandomData[A] {
def random: A
}