Skip to content

Instantly share code, notes, and snippets.

View adilakhter's full-sized avatar

Adil Akhter adilakhter

View GitHub Profile
@adilakhter
adilakhter / FreeConsole.scala
Created September 9, 2016 13:17 — forked from filippovitale/FreeConsole
FreeConsole – Simplest end to end example of Coyoneda and Free Monad in Scala
import scalaz.effect.IO
import scalaz.std.function._
import scalaz.{Coyoneda, Free, Monad, State, ~>}
object NonFunctor extends App {
// my simple algebra
sealed trait Console[A]
case class PrintLine(msg: String) extends Console[Unit]
case object ReadLine extends Console[String]
@adilakhter
adilakhter / State.scala
Created June 5, 2016 23:28 — forked from mpilquist/State.scala
Example of computing Fibonacci sequence with Scala 2.10 and memoizing State monad
trait State[S, A] {
val run: S => (S, A)
def apply(s: S): (S, A) =
run(s)
def eval(s: S): A =
apply(s)._2
@adilakhter
adilakhter / gist:f57aac9939d42eb510e9
Last active August 29, 2015 14:26 — forked from runarorama/gist:a8fab38e473fafa0921d
Compositional application architecture with reasonably priced monads
sealed trait Interact[A]
case class Ask(prompt: String)
extends Interact[String]
case class Tell(msg: String)
extends Interact[Unit]
trait Monad[M[_]] {
def pure[A](a: A): M[A]