This gist has been upgraded to a blog post here.
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
struct ExistsPrivate<A, F, B> | |
where F: Fn(&A) -> B { | |
a: A, | |
f: F | |
} | |
trait AnyExistsPrivate<B> { | |
fn extract(&self) -> 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
-- | A “flushing” 'stream', with an additional coalgebra for flushing the | |
-- remaining values after the input has been consumed. This also allows us to | |
-- generalize the output away from lists. | |
fstream | |
:: (Cursive t (XNor a), Cursive u f, Corecursive u f, Traversable f) | |
=> Coalgebra f b -> (b -> a -> b) -> Coalgebra f b -> b -> t -> u | |
fstream ψ g ψ' = go | |
where | |
go c x = | |
let fb = ψ c |
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
WHITESPACE ODDITY | |
by Paul Phillips, in eternal admiration of David Bowie, RIP | |
Bound Ctrl to Major mode | |
Bound Ctrl to Major mode | |
Read inputrc and set extdebug on | |
Bound Ctrl to Major mode (Ten, Nine, Eight, Seven, Six) | |
Connecting readline, options on (Five, Four, Three) | |
Check the syntax, may terminfo be with you (Two, One, Exec) |
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
target |
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
trait Monad[M[_]] { | |
def pure[A](a: A): M[A] | |
def flatMap[A, B](f: A => M[B]): M[A] => M[B] | |
def map[A, B](f: A => B): M[A] => M[B] = flatMap(a => pure(f(a))) | |
} | |
class EitherRightMonad[L] extends Monad[({type M[R] = Either[L, R]})#M] { | |
def pure[A](a: A): Either[L, A] = error("todo") | |
def flatMap[A, B](f: A => Either[L, B]): Either[L, A] => Either[L, B] = error("todo") | |
} |
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
// Some thoughts on IO and Futures | |
object Future { | |
// A future must have the option of performing IO during its computation; this | |
// is one of the primary uses of Futures. So we construct with an IO[A]. Construction | |
// is itself an effect because it forks execution of `a`. | |
def ioFuture[A](a: IO[A]): IO[Future[A]] | |
// Unit, but it has to be eager, so not super useful. What if it's not really a monad at all? |
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
trait Monad[M[_]] { | |
def pure[A](a: A): M[A] | |
def flatMap[A, B](f: A => M[B]): M[A] => M[B] | |
def map[A, B](f: A => B): M[A] => M[B] = flatMap(a => pure(f(a))) | |
} | |
object Id { | |
type Id[X] = X | |
implicit val M: Monad[Id] = sys.error("todo") |
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
trait Monad[M[_]] { | |
def pure[A](a: A): M[A] | |
def flatMap[A, B](f: A => M[B]): M[A] => M[B] | |
def map[A, B](f: A => B): M[A] => M[B] = flatMap(a => pure(f(a))) | |
} | |
class Reader[I] extends Monad[({type M[O] = Function1[I, O]})#M] { | |
def pure[A](a: A): Function1[I, A] = error("todo") | |
def flatMap[A, B](f: A => Function1[I, B]): Function1[I, A] => Function1[I, B] = error("todo") | |
} |