Skip to content

Instantly share code, notes, and snippets.


Vincent Marquez vmarquez

  • Irvine, CA
View GitHub Profile
runarorama / Adjunctions.scala
Last active December 2, 2019 19:58
Free/forgetful adjunctions
View Adjunctions.scala
import scalaz._, Scalaz._
// Adjunction between `F` and `G` means there is an
// isomorphism between `A => G[B]` and `F[A] => B`.
trait Adjunction[F[_],G[_]] {
def leftAdjunct[A, B](a: A)(f: F[A] => B): G[B]
def rightAdjunct[A, B](a: F[A])(f: A => G[B]): B
// Adjunction between free and forgetful functor.
paulp / universal.scala
Created May 6, 2015 16:21
existentials are inverted universals
View universal.scala
// [info] Running p.Run
// List(Fish(Bob, Esq.,12), Kitty(Thor, Esq.,java.awt.Color[r=255,g=200,b=0]))
import java.awt.Color
package p {
trait Pet[A] {
def name(a: A): String
def renamed(a: A, newName: String): A
View Command.scala
import scalaz._, Free.Trampoline, Scalaz._
sealed trait Command[T]
case class Wait(ms: Long) extends Command[Unit]
case object Evaluator extends (Command ~> Trampoline) {
override def apply[T](cmd: Command[T]) = cmd match {
case Wait(t) => Trampoline.done(Thread.sleep(t))
shajra /
Last active August 29, 2015 14:07
an open invitation

If you're interested in making great software by discovering the deeper truth of logic and abstraction, then this is an open invitation for your participation in our community. Unfortunately, most software communities are notoriously imbalanced, creating needless hurdles for people of various gender identities, races, religions, political groups, sexual orientation, and disabled communities (to name a few). Such exclusion services no one's best interest. So, we want to actively call for participation from anyone interested in making our software better.

We guarantee a safe environment where we promote well-reasoned arguments that lead to the greatest software we can possibly make. Unfortunately, along the way someone may make an error, or worse yet, exercise malice. We'll work hard towards keeping conversations objective and inclusive. Sometimes it's tough work, but we're completely invested in the process. If you feel a public forum has not served you well, please contact us privately so we have a ch

bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell
View gist:8739525
vpatryshev / ZFC in Java
Created November 29, 2013 20:52
Wrote this code in July 2008, implementing ZFC set theory in Java. Kind of funny; it worked.
View ZFC in Java
import java.util.List;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Arrays;
import java.util.Map;
import java.util.IdentityHashMap;
import java.util.LinkedList;
import java.util.SortedSet;
import java.util.TreeSet;
View KeyedLenses.scala
import scalaz.{LensFamily, Lens}
import Lens.{lensg, lensFamilyg}
object LensFns {
* A lens that requires a key be provided to extract B from A.
* @tparam A The record type.
* @tparam K The field key type.
shajra / Task.scala
Created August 23, 2013 03:34
integration code between Scalaz and Scala standard concurrency libraries.
View Task.scala
import concurrent.{ExecutionContext, Future => SFuture, Promise}
import util.Try
import _root_.scalaz.\/
import _root_.scalaz.concurrent.{Task => ZTask}
object Task {
def fromScala[A]
shajra /
Last active July 16, 2017 18:19
my thoughts on scala.util.Try, scalaz.concurrent.Task, and referential transparency

When scala.util.Try first came out, there was a lot of discussions about the validity of it's implementation. Some discussions got distracted with issues beyond the facts. Ultimately, the issue came down to the following:

  1. Is Try a monad?

  2. Does referential transparency (RT) apply in the presence of possible non-terminating or errant functions -- those returning ⊥?

Not requiring Try to be a monad is an easy solution to the whole problem. If

johnynek / async_stream.scala
Last active December 18, 2015 23:09
A simple API using Future and Promise to create an async stream.
View async_stream.scala
// could easily be ported to Scala Future
import com.twitter.util.{Promise, Future}
trait Source[+T] { self =>
def head: Option[T]
def tail: Future[Source[T]]
def map[U](fn: T => U): Source[U] = new Source[U] {
def head =
def tail = { }