Skip to content

Instantly share code, notes, and snippets.

View zraffer's full-sized avatar
🚀
let it be

Bay Raktar zraffer

🚀
let it be
View GitHub Profile
@codedot
codedot / Makefile
Last active May 21, 2018 00:36
Bitcoin proof of work in pure lambda calculus
all:
node work2mlc.js getwork.json 381353fa >test.mlc
lambda -pem lib.mlc -f test.mlc
clean:
@shiroginne
shiroginne / teh_drama.md
Last active May 25, 2023 09:39
драма с xored.com

Для тех, кто не следит за интеренетом, собрал драму в нескольких актах. ВОРНЕНГ: ссылки могут не работать, сохраняйте скриншоты.

Акт 1:

Статья на хабре https://habrahabr.ru/post/335876/ (читайте коментарии platoff)

Твиты которые могут содержать комментарии (если потёрли)

Акт 2:

@jdegoes
jdegoes / FreeMonad.scala
Created August 21, 2016 16:24
A pedagogical free(er) monad in 23 lines of Scala
sealed trait Free[F[_], A] { self =>
final def map[B](ab: A => B): Free[F, B] = Free.flatMap(self, ab andThen (Free.point[F, B](_)))
final def flatMap[B](afb: A => Free[F, B]): Free[F, B] = Free.flatMap(self, afb)
final def interpret[G[_]: Monad](fg: F ~> G): G[A] = self match {
case Free.Point(a0) => a0().point[G]
case Free.Effect(fa) => fg(fa)
case fm : Free.FlatMap[F, A] =>
val ga0 = fm.fa.interpret[G](fg)
ga0.flatMap(a0 => fm.afb(a0).interpret[G](fg))
}
@pbl64k
pbl64k / Para2.idr
Last active March 14, 2016 19:05
Parigot/Church-Scott encoding of naturals in CoC (by way of Idris)
Fix : (Type -> Type) -> Type
Fix f = {x : Type} -> (f x -> x) -> x
fold : Functor f => {x : Type} -> (f x -> x) -> Fix f -> x
fold k t = t k
embed : Functor f => f (Fix f) -> Fix f
embed s k = k (map (fold k) s)
project : Functor f => Fix f -> f (Fix f)
%default total
data Mu : (Type -> Type) -> Type where
In : f (Mu f) -> Mu f
out : Mu f -> f (Mu f)
out (In x) = x
data LstF : Type -> Type -> Type where
LF : ({c : Type} -> (Maybe (a, Unit -> c, b) -> c) -> c) -> LstF a b
@pbl64k
pbl64k / para.hs
Last active March 4, 2016 09:34
Possibly pointless? encoding of lists as their own paramorphisms.
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE Rank2Types #-}
import Data.Maybe
data Fix f = Fix { unFix :: f (Fix f) }
data ListF a b = LF { unLF :: forall c. (Maybe (a, (c, b)) -> c) -> c }
type List a = Fix (ListF a)
@patcon
patcon / INSTALL.md
Last active July 28, 2017 10:34
Installing why3 IDE for verifying sample Ethereum contract (Ubuntu 14.04)
# install ocaml and deps
apt-get install ocaml ocaml-native-compilers
apt-get install liblablgtk2-ocaml-dev liblablgtksourceview2-ocaml-dev libocamlgraph-ocaml-dev

# install opam from binaries (ocaml package manager)
# See https://opam.ocaml.org/doc/Install.html#Binarydistribution
wget https://raw.github.com/ocaml/opam/master/shell/opam_installer.sh -O - | sh -s /usr/local/bin/

#### OR
@chriseth
chriseth / BinarySearch.sol
Last active August 3, 2022 19:22
Verified binary search in sorted array
contract BinarySearch {
///@why3
/// requires { arg_data.length < UInt256.max_uint256 }
/// requires { 0 <= to_int arg_begin <= to_int arg_end <= arg_data.length }
/// requires { forall i j: int. 0 <= i <= j < arg_data.length -> to_int arg_data[i] <= to_int arg_data[j] }
/// variant { to_int arg_end - to_int arg_begin }
/// ensures {
/// to_int result < UInt256.max_uint256 -> (to_int arg_begin <= to_int result < to_int arg_end && to_int arg_data[to_int result] = to_int arg_value)
/// }
/// ensures {
@smarr
smarr / truffle-material.md
Last active March 16, 2023 14:06
Truffle: Languages and Material
@cb372
cb372 / jargon.md
Last active May 8, 2023 16:03
Category theory jargon cheat sheet

Category theory jargon cheat sheet

A primer/refresher on the category theory concepts that most commonly crop up in conversations about Scala or FP. (Because it's embarassing when I forget this stuff!)

I'll be assuming Scalaz imports in code samples, and some of the code may be pseudo-Scala.

Functor

A functor is something that supports map.