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 Primes where | |
open import Level using (_⊔_) | |
open import Coinduction | |
open import Function | |
open import Data.Empty | |
open import Data.Unit | |
open import Data.Nat | |
open import Data.Nat.Properties | |
open import Data.Nat.Divisibility |
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
with import <nixpkgs> { }; | |
package: | |
haskell.lib.overrideCabal package (p: { | |
isLibrary = false; | |
enableSharedExecutables = false; | |
postInstall = '' | |
rm -r $out/lib $out/share | |
''; | |
}) |
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 RankNTypes #-} | |
import Control.Lens | |
import Data.Functor.Apply | |
traversal1 | |
:: Traversal1 s t a b | |
-> Traversal s t a b | |
traversal1 t f = | |
unwrapApplicative . t (WrapApplicative . f) |
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
public class FP | |
{ | |
public static <A> A identity (A a) | |
{ | |
return a; | |
} | |
public static <A, B> A constant (A a, B b) | |
{ | |
return 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
module Compose where | |
open import Level | |
open import Function | |
open import Relation.Binary.PropositionalEquality | |
record Functor {α} (T : Set α → Set α) : Set (suc α) where | |
field | |
map : ∀ {A B : Set α} → (A → B) → T A → T B | |
identity : ∀ {A : Set α} → map id ≡ id {A = T 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
How do we add extra information to a tree? This has been called [The | |
AST Typing | |
Problem](http://blog.ezyang.com/2013/05/the-ast-typing-problem/). | |
After being hit with this problem in Roy's new type-inference engine, | |
I tried figuring out how to represent the algorithm. I eventually | |
realised that it looked like a comonadic operation. Turns out it's | |
been done before but I couldn't find any complete example. | |
Below is some literate Haskell to show how to use the Cofree Comonad |
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 AlaCarte where | |
-- Control.Monad.Free | |
data Free f a = Free (f (Free f a)) | Pure a | |
instance Functor f => Monad (Free f) where | |
Pure a >>= f = f a | |
Free r >>= f = Free (fmap (>>= f) r) | |
return = Pure |
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
#!/bin/sh | |
sudo mount -o remount,exec /tmp | |
if [ -x /usr/local/nixstrap/proot-x86_64 ] && [ -h ~/.nix-profile ]; then | |
echo "Launching shell with nix-* tools!" | |
exec /usr/local/nixstrap/proot-x86_64 -b /usr/local/nixstrap/nix-1.8-x86_64-linux:/nix bash --init-file ~/.nix-profile/etc/profile.d/nix.sh | |
fi | |
set -e |
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
# Adds node_modules/.bin to the PATH | |
npm_chpwd_hook() { | |
if [ -n "${PRENPMPATH+x}" ]; then | |
PATH=$PRENPMPATH | |
unset PRENPMPATH | |
fi | |
if [ -f package.json ]; then | |
PRENPMPATH=$PATH | |
PATH=$(npm bin):$PATH | |
fi |