This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Optional; | |
import java.util.function.BiFunction; | |
import java.util.function.Function; | |
// Profunctor Optics | |
// http://programming-journal.org/2017/1/7/ | |
public interface Optics { | |
static void main(final String[] args) { | |
System.out.println(Pair.<String, Optional<Pair<Integer, Boolean>>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.xml.pull._ | |
import scalaz._ | |
import Scalaz._ | |
trait Input[F[_]] { | |
type =>>[A, B] = StateT[Option, F[A], B] | |
def uncons[A](f: F[A]): Option[(F[A], A)] | |
def next[A]: (A =>> A) = StateT { uncons } | |
def none[A, B] = Option.empty[(F[A], B)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Monads { | |
trait Functor[F[_]] { | |
def map[A, B](fa: F[A])(f: A => B): F[B] | |
} | |
trait Monad[M[_]] extends Functor[M] { | |
self => | |
def unit[A](a: => A): M[A] |
NewerOlder