Skip to content

Instantly share code, notes, and snippets.

View edmundnoble's full-sized avatar
👋
Hi! My name is

Edmund Noble edmundnoble

👋
Hi! My name is
  • Toronto, Canada
View GitHub Profile
object TypeSafeBuilder {
type F
type T
case class Cat(name: String, age: Int)
object CatBuilder {
def apply() = new CatBuilder[F, F](None, None)
implicit class BuildableCatBuilder(cb: CatBuilder[T, T]) {
def build(): Cat = cb.hiddenBuild()
=================
[ACatenable1 Tests]
[laws]
[lawful semicategory]
associativity
[free semicategory]
foldMap
lift
[tests]
compose
Exception in thread "specs2-1" java.lang.StackOverflowError
at org.specs2.fp.Monad.ap(Monad.scala:19)
at org.specs2.fp.Monad.ap$(Monad.scala:18)
at org.specs2.control.eff.TimedFuture$$anon$1.ap(FutureEffect.scala:54)
at org.specs2.fp.Applicative.ap2(Applicative.scala:18)
at org.specs2.fp.Applicative.ap2$(Applicative.scala:17)
at org.specs2.control.eff.TimedFuture$$anon$1.ap2(FutureEffect.scala:54)
at org.specs2.fp.Applicative.apply2(Applicative.scala:33)
at org.specs2.fp.Applicative.apply2$(Applicative.scala:32)
at org.specs2.control.eff.TimedFuture$$anon$1.apply2(FutureEffect.scala:54)
package org.http4s
package server
package middleware
import cats.{~>, FlatMap, Functor}
import cats.data.{Kleisli, NonEmptyList}
import cats.effect.Effect
import cats.syntax.eq._
import cats.syntax.functor._
import cats.syntax.flatMap._
package org.http4s
package server
package middleware
import cats._
import cats.data.{Kleisli, OptionT}
import fs2.Stream._
import fs2._
import java.nio.charset.StandardCharsets
import org.http4s.headers._
@edmundnoble
edmundnoble / isolang.scala
Last active September 27, 2017 21:11
Showing off vim macros, for better or for worse
case object aa extends ISOLang
case object ab extends ISOLang
case object af extends ISOLang
case object am extends ISOLang
case object ar extends ISOLang
case object as extends ISOLang
case object ay extends ISOLang
case object az extends ISOLang
case object ba extends ISOLang
case object be extends ISOLang
trait FixT {
type T[_[_]]
def subst[F[_[_[_]]]](kt: F[T]): F[λ[k[_] => k[T[k]]]]
def unsubst[F[_[_[_]]]](kt: F[λ[k[_] => k[T[k]]]]): F[T]
}
package object matryoshka {
val FixI: FixT = new FixT {
type T[F[_]] = Fix[F]
def subst[F[_[_[_]]]](kt: F[T]): F[λ[k[_] => k[T[k]]]] = kt
trait EitherTInstances {
implicit final def eitherMonadLayerControl[M[_], E]
(implicit M: Monad[M]): MonadLayerControl.Aux[EitherTC[M, E]#l, M, EitherC[E]#l] = {
new MonadLayerControl[EitherTC[M, E]#l, M] {
type State[A] = E Either A
val outerInstance: Monad[CurryT[EitherTCE[E]#l, M]#l] =
EitherT.catsDataMonadErrorForEitherT
val innerInstance: Monad[M] = M
package scalaz
package data
import scalaz.meta.Ops
import scala.reflect.macros.whitebox.Context
import scala.language.experimental.macros
final class IdOps[A](self: A) extends Ops {
type O = IdOpsImpls.type
def squared: (A, A) = macro Ops.inline0
def inline0(c: whitebox.Context): c.Tree = {
import c.universe._
val q"new ${cl: TypeTree}(..$p)" = c.prefix.tree
val moduleTySym = cl.tpe.member(TypeName("O")).typeSignature
val module = Ident(moduleTySym.termSymbol)
val pre = c.prefix
val appName = c.macroApplication.symbol.name.toString
q"$module.${TermName(appName)}(${p.head})"
}