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-3.13 --install-ghc runghc --package base --package attoparsec --package text | |
{-# LANGUAGE OverloadedStrings #-} | |
import Control.Applicative ((<|>), many) | |
import Data.Attoparsec.Text (Parser) | |
import Data.Attoparsec.Combinator (lookAhead) | |
import qualified Data.Attoparsec.Text as P -- (*) | |
import Data.Char (chr) |
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-3.13 --install-ghc runghc --package base --package bytestring --package iso3166-country-codes --package lens --package QuickCheck --package syb --package tagged --package uri-bytestring | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE DeriveDataTypeable #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE RecordWildCards #-} |
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
{-# LANGUAGE DataKinds #-} | |
import Data.Proxy (Proxy(Proxy)) | |
import GHC.TypeLits (symbolVal) | |
main = putStrLn $ symbolVal (Proxy :: Proxy "Hello, world!") |
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
let | |
inherit (builtins) map; | |
inherit ((import <nixpkgs> {}).lib) | |
fold hasSuffix stringToCharacters concatStrings any; | |
in rec { | |
inits = fold (x: y: [[]] ++ map (z: [x] ++ z) y) [[]]; | |
hasInfix = i: str: any (x: hasSuffix i (concatStrings x)) (inits (stringToCharacters str)); | |
} |
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
let | |
inherit (builtins) isAttrs typeOf toJSON; | |
inherit ((import <nixpkgs> {}).lib) mapAttrsRecursive; | |
in rec { | |
show = value: if typeOf value == "lambda" then "<LAMBDA>" else value; # XXX: Not sure how to discriminate between functions and 'PRIMOP'. | |
json = value: toJSON (if ! isAttrs value then show value else mapAttrsRecursive (_: show) value); | |
} |
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 bash | |
file "$(realpath $1)" | grep -q "shared object" || { | |
echo "Argument error: address a shared object file" >&2 | |
exit 1 | |
}; | |
find $(nix-store -q --referrers "$1") -executable -type f -name '*.so' -exec sh -c ' | |
realpath {} | xargs ldd | grep -o "/nix/store/.* " | xargs realpath | sed "s,^,$(nix-store -q --deriver {}):," | |
' ';' | sort -u | grep "$(realpath $1)" | grep -Po '^.*(?=:)' |
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
0 this well-oiled machine: | |
barters capacity for | |
"this well-oiled machine:" | |
1 moral nihilism: | |
as if spurning direction | |
would yield a scalar |
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
| Upstream output | Upstream input | Downstream input | Downstream output | Base monad | Return value | |
Proxy a' a b' b m r | a' | a | b' | b | m | r | |
Effect m r | Void | () | () | Void | m | r | |
Pipe a b m r | () | a | () | b | m | r | |
Producer b m r | Void | () | () | b | m | r | |
Consumer a m r | () | a | () | Void | m | r | |
Client a' a m r | a' | a | () | Void | m | r | |
Server b' b m r | Void | () | b' | b | m | r |
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 Prelude hiding (span, head, null) | |
import Control.Monad (liftM2) | |
import Data.Vector (Vector, null, empty, cons, span, head, thaw, freeze) | |
import qualified Data.Vector.Algorithms.Intro as Intro (sort) | |
group :: Eq a => Vector a -> Vector (Vector a) | |
group vs | null vs = empty | |
| otherwise = a `cons` group b where (a, b) = span (== head vs) vs | |
sort :: Ord a => Vector a -> IO (Vector 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
-- Quick and dirty: | |
-- | |
-- Modular decomposition of a digraph into a set of subgraphs such that, in | |
-- each subgraph $s$, from a specific base vertex $b$, there exists a path to | |
-- every other vertex in $s$, and no path to base vertices in the rest of the | |
-- supergraph. | |
import Control.Applicative ((<$>),(<*>)) | |
import Data.Graph.Wrapper (Graph, vertices, vertex, fromVerticesEdges, reachableVertices, edges) | |
import Data.List (intersect, union, find) |
NewerOlder