Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
List of Functions
sealed trait FList[F[_]] extends Product with Serializable
object FList {
final case class Last[F[_], A, B](f: A => F[B]) extends FList[F]
final case class Cons[F[_], A, B, Tail <: FList[F]](f: A => F[B], tail: Tail) extends FList[F]
}
implicit class FunOps[F[_], A, B](f: A => F[B]) extends AnyVal {
def toFList: FList.One[F, A, B] = FList.One(f)
def +:[C, D](f: C => F[D]): FList.Cons[F, C, D, FList.One[F, A, B]] = FList.Cons(f, toFList)
}
implicit class FListOps[F[_], Tail <: FList[F]](tail: Tail) extends AnyVal {
def +:[A, B](f: A => F[B]): FList.Cons[F, A, B, Tail] = FList.Cons(f, tail)
}
trait FListFunc[F[_], O]] {
def runFun[A, B](f: A => F[B]): O // SAM
def apply[FL <: FList[F]](flist: FL): NonEmptyList[O] = ...
def fold[FL <: FList[F]](flist: FL)(implicit O: Monoid[O]): O = ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment