Skip to content

Instantly share code, notes, and snippets.

@nc6
nc6 / Hanging.lean
Created May 21, 2021 19:25
Unexpected hanging paradox
import Init.Data.Ord
namespace Weekday
/- Weekdays -/
inductive Weekday where
| monday : Weekday
| tuesday : Weekday
| wednesday : Weekday
| thursday : Weekday
@nc6
nc6 / gist:a485930aa39c7a758c75009898403555
Last active January 22, 2019 16:39
How to build a file created with cabal2nix
nix-repl> hp = pkgs.haskell.packages.ghc863.override { overrides = self: super: rec { funflow = self.callPackage ./. {}; }; }
nix-repl> :b hp.funflow
@nc6
nc6 / index.html
Last active October 3, 2018 12:15
Haskell Exchange Comic
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css">
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg)">
<scene id="scene1">
<label t="translate(0,346)">
{-# LANGUAGE Arrows #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-
I have a type as the following:
```data Foo =
Foo1 (Either String Int)
| Foo2 (Either String Char)
| Foo3 (Either String Bar)
...
```
There may end up being a lot of these. All will have `Either String a` inside. There are a bunch of functions taking a `Foo` argument. In most cases, the behaviour of how to treat a `Left` is the same, but for one, where it's important to know the constructor. I can't thus pull the `Either` out to the top level. Nor can I easily just turn the constructor into a tag, because it determines the type inside the `Right`
@nc6
nc6 / update_sublime_nixpkg.sh
Created July 11, 2017 15:29
Script to update nixpkgs derivation for sublime3-dev builds.
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p go-pup
WD="${1:-$HOME/nixpkgs}"
NIXEXPR="$WD/pkgs/applications/editors/sublime3-dev/default.nix"
LATEST_BUILD=$( curl -s http://www.sublimetext.com/3dev \
| pup "h2" | grep Build | cut -d" " -f 3 | sort -rn | head -n 1)
SHA_32=$(curl -s "https://download.sublimetext.com/sublime_text_3_build_${LATEST_BUILD}_x32.tar.bz2" \
| sha256sum | cut -d' ' -f1)
@nc6
nc6 / config.nix
Created July 7, 2017 09:57
numhask build
# ~/.nixpkgs/config.nix
{ pkgs }:
{
allowUnfree = true;
packageOverrides = self: rec {
haskellPackages = self.haskellPackages.override {
overrides = hsSelf: hsSuper: {
numhask = hsSelf.callPackage /home/nc/proj/numhask {};
@nc6
nc6 / Main.hs
Last active March 30, 2016 11:26
Example of using new Vinyl ElField (open universe field types)
{-# LANGUAGE DataKinds, FlexibleContexts, TypeOperators #-}
module Main where
import Data.Proxy
import Data.Vinyl
import Data.Vinyl.Derived
import Data.Vinyl.Functor
import Control.Applicative
@nc6
nc6 / Main.hs
Created December 19, 2014 12:10
dumpNodeStats bug report.
{-# LANGUAGE LambdaCase #-}
module Main where
import Control.Applicative
import Control.Distributed.Process
import Control.Distributed.Process.Node
import qualified Network.Transport.TCP as TCP
### Keybase proof
I hereby claim:
* I am nc6 on github.
* I am nclarke (https://keybase.io/nclarke) on keybase.
* I have a public key whose fingerprint is 2D84 857B 3ECB A75B 2CCE 0205 8EE7 C3E6 6B79 6305
To claim this, I am signing this object: