Skip to content

Instantly share code, notes, and snippets.

View nponeccop's full-sized avatar

nponeccop

  • Barcelona, Spain
  • 03:15 (UTC +03:00)
View GitHub Profile
@nponeccop
nponeccop / build.sh
Created August 12, 2022 20:13
podman tarball trick
#!/bin/bash
set -ex -o pipefail
podman build . -t small-tar
podman rm small-tar || true
podman create --name small-tar small-tar /bin/dummycmd
podman cp small-tar:/rootfs.tar rootfs.tar
podman rm small-tar || true
@nponeccop
nponeccop / deps.dot
Created July 13, 2018 02:05
Sample dependencies of MetaCPAN-Client
digraph Foo {
"MetaCPAN-Client" -> "LWP-Protocol-https";
"LWP-Protocol-https" -> "Test-RequiresInternet";
"LWP-Protocol-https" -> "libwww-perl";
"libwww-perl" -> "Test-RequiresInternet";
"libwww-perl" -> "Test-Fatal";
"Test-Fatal" -> "Try-Tiny";
"Try-Tiny" -> "CPAN-Meta-Check" [style=dotted];
"CPAN-Meta-Check" -> "Test-Deep";
"Try-Tiny" -> "Capture-Tiny" [style=dotted];
@nponeccop
nponeccop / Cont.hs
Created March 3, 2017 20:10
State monad using Cont
{-# LANGUAGE NoMonomorphismRestriction, Rank2Types #-}
import Control.Monad.Cont
type State s v = s -> (s, v)
set :: a -> State a ()
set x = const (x, ())
get :: State a a
get = \s -> (s, s)
@nponeccop
nponeccop / ListAlgebras.hs
Last active February 11, 2017 22:50
RamdaJS reduceBy() in Haskell using recursion-schemes
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TypeFamilies #-}
import Data.Functor.Foldable
import Data.Maybe
import qualified Data.Map as M
listCata :: ListCata a b
listCata = cata
reduceBy :: Ord k => ListAlgebra t b -> (t -> k) -> [t] -> M.Map k b
@nponeccop
nponeccop / README.md
Created January 27, 2017 17:53
SimpleChecker.hs

A part of Hindley Milner type inference/checker

Checks only applications, there are no lets or lambda abstractions :)

Control.Unification comes from unification-fd package.
Unifier.Unifier and Unifier.Restricted can be copy-pasted from https://github.com/nponeccop/HNC/tree/master/Unifier

@nponeccop
nponeccop / mini-checker.hs
Created January 20, 2017 17:56
Minimal Hindley Milner type checker example using HNC Unifier
{-# LANGUAGE LambdaCase #-}
import Unifier.Unifier
import Unifier.Restricted
import Control.Monad.Identity
import Control.Unification (freeVar, freshen, applyBindings)
import Control.Unification.IntVar
import Control.Monad.Trans
import qualified Data.Map as M
data Expression = Atom String | App Expression Expression
@nponeccop
nponeccop / min-unifier-hn.hs
Created January 19, 2017 01:14
Minimal client for HNC Unifier.Unifier module
{-# LANGUAGE NoMonomorphismRestriction, FlexibleContexts #-}
import Control.Unification (freeVar)
import Control.Unification.IntVar
import Control.Monad.Trans
import Control.Monad.Identity
import Unifier.Unifier
import Unifier.Restricted
t = UTerm . T
ar a b = UTerm $ TT [a, b]
digraph smtp {
init -> A [label=greet];
A -> done [label=ehlo];
}
@nponeccop
nponeccop / .block
Last active June 30, 2016 19:56 — forked from mbostock/.block
Pan & Zoom Axes
license: gpl-3.0

10 charts of 1070 points each

The axes are still the bottleneck, so I reduced tick count