Skip to content

Instantly share code, notes, and snippets.

@nrolland
nrolland / PracticalNix.md
Last active January 10, 2022 15:32
Practical Nix
@nrolland
nrolland / composition.hs
Created April 29, 2021 17:33
foldr and foldl on ∫ A : A^{op} ⊗ A → Set
-- post-composition
foldl_foldr f z l = foldr (.>) id (foldr (\x -> (flip f x :)) [] l) z
-- f x .> (f y .> (f z .> id)) rs = f z (f y (f x rs)) -- .> quite not lazy
-- pre-composition = mieux que remplacement des ctors
foldr_foldr f z l = foldr (.) id (foldr (\x -> (f x :)) [] l) z
#!/usr/bin/env stack
-- stack --resolver lts-17.10 script
-- or
-- stack --install-ghc --resolver lts-17.10 runghc --package base-unicode-symbols
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UnicodeSyntax #-}
#! /usr/bin/env nix-shell
#! nix-shell -i runghc -p "haskellPackages.ghcWithPackages(p: with p; [])"
#! nix-shell -I nixpkgs=channel:nixos-20.9
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
@nrolland
nrolland / TABA.hs
Created April 28, 2021 05:03
TABA convolution Danvy / GoldBerg
#!/usr/bin/env stack
-- stack --resolver lts-17.10 script
(.>) :: (a -> b) -> (b -> c) -> (a -> c)
f .> g = g . f
-- Convolution from "There and back again" Danvy GoldBerg -- https://www.brics.dk/RS/01/39/BRICS-RS-01-39.pdf
convWalk xs ys = walk xs (\_ b -> b)
where
@nrolland
nrolland / gist:82b10bdba7042610b47efa68b5a63bcb
Created December 10, 2018 18:11
emacs themes in (defun dotspacemacs/init ()
dotspacemacs-themes '(zenburn zen-and-art white-sand underwater ujelly twilight twilight-bright twilight-anti-bright toxi tao tao-yang tao-yin tangotango tango-plus tango-2 sunny-day brin dorsey fogus graham granger hickey junio mccarthy odersky ritchie spolsky wilson subatomic256 subatomic spacegray soothe solarized-dark solarized-light solarized soft-stone soft-morning soft-charcoal smyx seti reverse rebecca railscasts purple-haze professional planet phoenix-dark-pink phoenix-dark-mono organic-green omtose-darker omtose-softer oldlace occidental obsidian noctilux naquadah mustang monokai monochrome-bright monochrome molokai moe-dark moe-light moe minimal-light minimal material-light material majapahit-dark majapahit-light madhat2r lush light-soap kaolin-aurora kaolin-breeze kaolin-bubblegum kaolin-dark kaolin-eclipse kaolin-fusion kaolin-galaxy kaolin-light kaolin-mono-dark kaolin-ocean kaolin-valley-dark kaolin-valley-light jbeans jazz ir-black inkpot heroku hemisu-dark hemisu-light hemisu hc-zenburn g
#! /usr/bin/env nix-shell
#! nix-shell -i "emacs --script" -p "pkgs.emacsWithPackages(epkgs: (with epkgs.melpaPackages; [ ox-gfm ]))"
#! nix-shell -I nixpkgs=channel:nixos-18.09
(package-initialize)
(require 'org)
(require 'ox-gfm)
(org-gfm-publish-to-gfm nil "myorgfile.org" ".")
#! /usr/bin/env nix-shell
#! nix-shell -i "emacs --script" -p "pkgs.emacsWithPackages(epkgs: (with epkgs.melpaPackages; [ dash ]))"
#! nix-shell -I nixpkgs=channel:nixos-18.03
(package-initialize)
(require 'dash)
(message "Hi")
#!/usr/local/bin/emacs --script
(package-initialize)
(require 'dash)
data Tree = Leaf Int
| Node Tree Tree deriving Show
repmin t = tr
where (mn, tr) = walk mn t