Skip to content

Instantly share code, notes, and snippets.

View benhutchison's full-sized avatar

Ben Hutchison benhutchison

View GitHub Profile
@benhutchison
benhutchison / MemberInTransform.scala
Created September 27, 2016 23:08 — forked from etorreborre/MemberInTransform.scala
transform a MemberIn
object Test {
import cats._
import cats.data._
import cats.implicits._
import org.atnos.eff._
import org.atnos.eff.all._
import org.atnos.eff.syntax.all._
case class Address()
@benhutchison
benhutchison / ComputationOrder1.scala
Last active August 20, 2016 13:18 — forked from labra/ComputationOrder1.scala
Another example with computation order...
import cats._, data._
import org.atnos.eff._, all._
import org.atnos.eff.syntax.all._
object ComputationOrder {
//// With 3 effects, it fails when I use runNel at the beginning
type C3 = Fx.fx3[State[String,?],Choose,Validate[String,?]]
// The following, models a HAL Resource based on HAL specification:
// http://stateless.co/hal_specification.html
// And provides Argonaut JSON encoders for that model
// (Argonaut is a purely functional Scala JSON library)
// http://argonaut.io/
import shapeless._
import shapeless.ops.hlist.{ToTraversable, Mapper}
import argonaut._, Argonaut._
import scala.language.existentials
import scala.language.higherKinds
@benhutchison
benhutchison / contravariant.scala
Created October 31, 2012 01:38 — forked from eed3si9n/contravariant.scala
implementation of Equal typeclass using contravariance - difficulties resolved
object Test extends App {
trait CanEqual[-A] {
def equals(a1: A, a2: A): Boolean
}
object CanEqual {
def apply[A](implicit ev: CanEqual[A]): CanEqual[A] = ev
def equals[A](f: (A, A) => Boolean): CanEqual[A] = new CanEqual[A] {
def equals(a1: A, a2: A): Boolean = f(a1, a2)
}