Skip to content

Instantly share code, notes, and snippets.

@MateuszKubuszok
Created October 27, 2020 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MateuszKubuszok/712aafafb5d37b8aa66bbd2cfc697a60 to your computer and use it in GitHub Desktop.
Save MateuszKubuszok/712aafafb5d37b8aa66bbd2cfc697a60 to your computer and use it in GitHub Desktop.
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