def hash(a: A): Int
makes me sad. What about hashing to 64 bits or SL2 Fp?def MapHash[A, B: Hash]: Hash[Map[A, B]]
is a bit odd. Why notA: Hash
?reflexiveLaw + symmetryLaw + transitivityLaw
is too weak for "equality". This defines a general equivalence relationship only.val AnyEqual: Equal[Any]
is worrisome, considering all the resolution bugs!val DoubleEqual: Equal[Double]
should be implemented usingjava.lang.Double.doubleToRawLongBits
.- A combintation of [
trait Ord[-A] extends Equal[A]
](https://github.com/zio/zi
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
// This sums up my understanding of | |
// https://github.com/lampepfl/dotty/issues/9359 | |
// and https://github.com/lampepfl/dotty/issues/8430 | |
// == on AnyVal does not imply singleton type equality | |
class Test[A](val x: Int) extends AnyVal | |
def coerce1[A, B](a: A): B = { | |
val x = new Test[A](1) | |
val y = new Test[B](1) |
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
trait CharReader { | |
def current(): Int | |
def advance(): Unit | |
} | |
object CharReader { | |
final val EOF: Int = -1 | |
final val EOB: Int = -2 | |
@silent final class FromString(val text: String, end: Int) extends CharReader { | |
var index = 0 |
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 itertools import * | |
# Compute our D(pi) function | |
elements = {} | |
for p in permutations([1,2,3,4]): | |
d = [i+1 for i in range(3) if p[i] > p[i + 1]] | |
elements[p] = frozenset(d) | |
# Make a graph with the given pi < tau relation. | |
graph = {} |
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 cats.Eval | |
import cats.syntax.all._ | |
trait Eq[A] { | |
def eqv(x: A, y: A): Eval[Boolean] | |
} | |
trait Eq1[F[_]] { | |
def eqv1[A](x: F[A], y: F[A])(implicit A: Eq[A]): Eval[Boolean] | |
} |
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 cats.Eq | |
trait Eq1[F[_]] { | |
def eqv1[A](x: F[A], y: F[A])(implicit A: Eq[A]): Boolean | |
} | |
final case class Fix[F[_]](unfix: F[Fix[F]]) | |
object Fix { | |
implicit def eqv[F[_]: Eq1]: Eq[Fix[F]] = new Eq[Fix[F]] { | |
def eqv(x: Fix[F], y: Fix[F]): Boolean = |
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
#if __ENDIAN_LITTLE__ | |
# define NATIVE_LITTLE_ENDIAN 1 | |
#endif | |
#if __LITTLE_ENDIAN__ | |
# define NATIVE_LITTLE_ENDIAN 1 | |
#endif | |
#define BLAKE2S_BLOCKBYTES 64 |
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 collections import namedtuple | |
Add = namedtuple('Add', 'args') | |
Xor = namedtuple('Xor', 'left right') | |
Rot = namedtuple('Rot', 'left right') | |
Input = namedtuple('Input', 'name') | |
Const = namedtuple('Const', 'value') | |
Set = namedtuple('Set', 'var expr') | |
IV0p = 0x6b08e647 |
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 scala.util.control.NonFatal | |
type && [F[_], G[_]] = [x] =>> F[x] & G[x] | |
trait CombinatorErrors[E] { | |
def tupleLeft(e: E): E | |
def tupleRight(e: E): E | |
def tupleBoth(e1: E, e2: E): E | |
} |
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 scala.util.control.NonFatal | |
trait CombinatorErrors { | |
type Error | |
def tupleLeft(e: Error): Error | |
def tupleRight(e: Error): Error | |
def tupleBoth(e1: Error, e2: Error): Error | |
} | |
trait Reader[-C, +A] { A => |