Skip to content

Instantly share code, notes, and snippets.

View andyscott's full-sized avatar
🌲

Andy Scott andyscott

🌲
View GitHub Profile
object Evidence extends App {
class Foo[A]
class Bar[A]
class Zed[A]
// FirstK will find the first available evidence for entries in a TListK
{
implicit val zedForString: Zed[String] = new Zed[String]
require 'formula'
class Thrift < Formula
homepage 'http://thrift.apache.org'
head 'http://svn.apache.org/repos/asf/thrift/trunk'
url 'https://archive.apache.org/dist/thrift/0.7.0/thrift-0.7.0.tar.gz'
depends_on 'boost'
def install
@andyscott
andyscott / hkt.rs
Created January 4, 2018 22:16 — forked from AZaviruha/hkt.rs
Higher-kinded type trait
use std::rc::Rc;
trait HKT<U> {
type C; // Current type
type T; // Type with C swapped with U
}
macro_rules! derive_hkt {
($t:ident) => {
impl<T, U> HKT<U> for $t<T> {
import iota._
import iota.TList.::
import iota.TList.Op
import iota.syntax.inject._
def foldTo[B]: CopFoldTo[B] = new CopFoldTo[B]
class CopFoldTo[B] {
// library code to add to iota
def apply[L <: TList, LF <: TList](a: Cop[L])(fs: Prod[LF])(
def foldTo[B]: CopFoldTo[B] = new CopFoldTo[B]
class CopFoldTo[B] {
def apply[L <: TList, LF <: TList](a: Cop[L])(fs: Prod[LF])(
implicit ev: TList.Compute.Aux[Op.Map[? => B, L], LF]
): B =
fs.values(a.index).asInstanceOf[Any => B].apply(a.value)
}
object Finn
import shapeless.Generic
import shapeless.HList
import shapeless.ops.hlist.FilterNot
import java.util.UUID
// compare case classes but ignore UUID fields in the comparison
object ExampleApp {
final case class Foo(
[debug] Getting org.scala-sbt:compiler-interface:0.13.15:component from component compiler for Scala 2.12.2-bin-typelevel-4
[debug] Getting org.scala-sbt:compiler-interface:0.13.15:component from component compiler for Scala 2.12.2-bin-typelevel-4
[debug] Running cached compiler 28e7910f, interfacing (CompilerInterface) with Scala compiler version 2.12.2-bin-typelevel-4
[debug] Calling Scala compiler with arguments (CompilerInterface):
[debug] -deprecation
[debug] -encoding
[debug] utf-8
[debug] -explaintypes
[debug] -feature
[debug] -language:existentials
/*
* Copyright 2016-2017 47 Degrees, LLC. <http://www.47deg.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package iota_bench
import iota._
import cats._
import cats.arrow.FunctionK
import cats.data.{ State => _, _ }
import cats.free._
import org.scalacheck._
abstract class LiteralValue[S] {
def value: S
}
object LiteralValue {
def apply[S](implicit ev: LiteralValue[S]): LiteralValue[S] = ev
implicit def makeLiteralValue[S <: Singleton]: LiteralValue[S] =
macro LiteralValueMacros.makeLiteralValue[S]
}