This file contains hidden or 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
| package adjunction | |
| import cats._ | |
| /** | |
| * An Adjunction is a relationship between two functors: | |
| * - `F`, the "left-adjoint" | |
| * - `G`, the "right-adjoint" | |
| * |
This file contains hidden or 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
| adjunction | |
| import cats._ | |
| abstract class Adjunction[F[_], G[_]] { self => | |
| def left[A,B](a: A)(f: F[A] => B): G[B] | |
| def right[A,B](fa: F[A])(f: A => G[B]): B | |
| def unit[A](a: A): G[F[A]] = |
This file contains hidden or 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
| package dogs | |
| import Predef._ | |
| import dogs.Order.{GT, EQ, LT, Ordering} | |
| import dogs.std.intOrder | |
| import scala.annotation.tailrec | |
| import scala.math | |
| sealed abstract class BinaryTree[A] { | |
| import BinaryTree._ |
This file contains hidden or 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
| def runTraverseRWST[F[_], G[_], R, W: Monoid, S, A, B](fa: F[A])(f: A => RWST[G,R,W,S,B])(r: R, s: S)(implicit F: Traverse[F], G: Monad[G]): G[(W,F[B],S)] = { | |
| F.traverse[({type λ[α]=RWST[G,R,W,S,α]})#λ,A,B](fa)(f)(RWST.rwstMonad[G,R,W,S]).run(r,s) | |
| } | |
This file contains hidden or 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
| class Elipse(val width: Double, val height: Double) | |
| // circle is a special case of elispse where width and height are the same | |
| class Circle(r: Double) extends Elipse(r, r) | |
| // typeclass to calculate the Area of a T | |
| trait Area[-T] { | |
| def area(t: T): Double | |
| } |
This file contains hidden or 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
| package cats | |
| package effect | |
| import java.util.concurrent.CountDownLatch | |
| /** | |
| * A computation of an A value | |
| */ | |
| sealed trait Comp[A] { | |
| import Comp._ |
This file contains hidden or 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
| convert -quality 100 -density 300x300 strace-zine.pdf'[0,2,4,6]' 'strace-single%d.gif | |
| convert -quality 100 -density 300x300 strace-zine.pdf'[1,3,5,7]' -rotate 180 'strace-single%d.gif' | |
| convert strace-single<0-8>.gif strace-fixed.pdf #<0-8> is probably a zsh only thing, * would probably work ⏎ |
This file contains hidden or 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
| from abc import ABCMeta, abstractmethod | |
| import sys | |
| # lets get one thing straight right out of the box: | |
| def fail(e): | |
| import traceback | |
| with open("/tmp/tb", "w") as f: | |
| traceback.print_exc(e, f) |
This file contains hidden or 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 scalaz._ | |
| import Maybe._ | |
| case class CofreeNEL[A](cf: Cofree[Maybe, A]) { | |
| def +:(a: A): CofreeNEL[A] = CofreeNEL(Cofree(a, just(cf))) | |
| def head: A = cf.head | |
| def tail: Maybe[CofreeNEL[A]] = cf.tail.map(CofreeNEL.apply) | |
| def map[B](f: A=>B): CofreeNEL[B] = CofreeNEL(cf map f) | |
| def flatMap[B](f: A => CofreeNEL[B]): CofreeNEL[B] = CofreeNEL(Bind[({type l[A]=Cofree[Maybe, A]})#l].bind(cf)(f andThen (_.cf))) |
This file contains hidden or 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 scalaz._ | |
| import Scalaz._ | |
| object IsItAProfunctor extends App { | |
| case class Foo(f: Double) | |
| val validateDouble: Double ⇒ Validation[String,Double] = {d ⇒ | |
| if(d < 0) "less than zero".fail | |
| else d.success |