This file contains 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
// Go to twitter.com and paste this into the js console to block all verified users (slowly) | |
class CheckieBlock { | |
constructor() { | |
this.waitMs = 10*1000; | |
this.jitMs = 2*1000; | |
this.blockLimit = 1000; | |
this.seen = new Set(); | |
} | |
sleep() { |
This file contains 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
-- | 'LogicT' is a great monad transformer for backtracking control, | |
-- but if you just layer with a 'State' monad, you won't backtrack state. | |
-- By that I mean at all choice points '(<|>)' or 'interleave', we will | |
-- save part of the state and reset it when retrying alternative branches. | |
module BacktrackingStateSearch | |
( TrackSt (..) | |
, Track | |
, observeManyTrack | |
, runManyTrack | |
) where |
This file contains 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 ShinKage on FP Slack | |
mapName : (String -> String) -> Name -> Name | |
mapName f (UN n) = UN (f n) | |
mapName f (MN n i) = (MN (f n) i) | |
mapName f (NS ns n) = (NS ns (mapName f n)) | |
mapName f (DN n realn) = (DN (f n) realn) | |
mapName f (RF n) = RF (f n) | |
appTyCon : List String -> Name -> TTImp | |
appTyCon ns n = foldl (\tt, v => `(~(tt) ~(IBindVar EmptyFC v))) (IVar EmptyFC n) ns |
This file contains 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
module Inj | |
import Decidable.Equality | |
import Decidable.Order | |
-- These definitions would go in some stdlib | |
public export | |
interface Equivalence ty inj => Inj (ty : Type) (inj : ty -> ty -> Type) where | |
useInj : {x, y: ty} -> inj x y -> x = y |
This file contains 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.annotation.tailrec | |
import scala.collection.immutable.SortedMap | |
import scala.collection.mutable | |
import scala.language.higherKinds | |
import scala.util.Random | |
import scala.util.control.TailCalls.{TailRec, done} | |
sealed trait KArrow[F[_], A, B] extends Product with Serializable | |
object KArrow { | |
final case class KMap[F[_], A, B](f: A => B) extends KArrow[F, A, B] |
This file contains 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
-- | Fun inspired by Selective | |
-- http://hackage.haskell.org/package/selective | |
module FreeSelective where | |
import Control.Monad (MonadPlus (..)) | |
import Data.Functor.Compose | |
import GHC.Exts (Constraint) | |
import Data.Map (Map) | |
import qualified Data.Map as Map | |
import Prelude |
This file contains 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
#!/usr/bin/env stack | |
-- stack --resolver lts-13.9 --install-ghc runghc --package aeson --package tasty --package text | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE DerivingVia #-} | |
{-# LANGUAGE DuplicateRecordFields #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE UndecidableInstances #-} |
This file contains 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
#!/usr/bin/env stack | |
-- stack --resolver lts-13.9 --install-ghc runghc --package aeson --package tasty --package text | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE DerivingVia #-} | |
{-# LANGUAGE DuplicateRecordFields #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
import Data.Aeson |
This file contains 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 example | |
import cats.~> | |
import org.scalatest.FunSuite | |
object CopSpec { | |
final case class Foo[+A](value: A) | |
final case class Bar[+A](value: A) | |
final case class Baz[+A](value: A) |
This file contains 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.languageFeature.higherKinds | |
import cats.{Applicative, Id, ~>} | |
object Shapes { | |
case class Child[F[_]](nickname: F[String], age: F[Int]) | |
case class Adult[F[_]](job: F[String], innerChild: Child[F]) | |
class ApplicativeTrans[F[_]](implicit applicativeF: Applicative[F]) extends ~>[Id, F] { | |
override def apply[A](value: A): F[A] = applicativeF.pure(value) |
NewerOlder