Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE EmptyDataDeriving #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE RankNTypes #-}
@fieldstrength
fieldstrength / Oceanic.json
Created May 17, 2022 12:53
iTerm2 theme Oceanic
{
"Ansi 6 Color" : {
"Green Component" : 0.73333334922790527,
"Blue Component" : 0.73333334922790527,
"Red Component" : 0
},
"Tags" : [
],
"Ansi 12 Color" : {
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UndecidableInstances #-}
module API.Types.Deriving where
@fieldstrength
fieldstrength / Things.hs
Created July 19, 2018 13:28
Constrained typed extractions with GADTs
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ViewPatterns #-}
module Things where
-- Data
data X = X String Bool Char
@fieldstrength
fieldstrength / tmux.md
Created June 28, 2018 10:01 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

module UniqueList
import Data.List
%default total
data UniqueListProof : List a -> Type where
UNil : UniqueListProof []
UCons : {xs : List a}
-> (x : a)
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Matrices
-- Vector stuff ~ maybe put Prelude.Vect
||| Dot product between numerical vectors
dot : Num a => Vect n a -> Vect n a -> a
dot w v = sum (zipWith (*) w v)
||| Numerical vector times a scalar of the appropriate type
@fieldstrength
fieldstrength / gist:35f5b8870c2913b56cf8
Created October 24, 2015 13:30
Pythagorean triples
$ ghci
GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help
λ> let pythag n = [ (x,y,z) | x <- [1..n], y <- [1..x], z <- [1..n], x^2+y^2 == z^2 ]
λ> length $ pythag 100
52
λ> pythag 100
[(4,3,5),(8,6,10),(12,5,13),(12,9,15),(15,8,17),(16,12,20),(20,15,25),(21,20,29),(24,7,25),(24,10,26),(24,18,30),(28,21,35),(30,16,34),(32,24,40),(35,12,37),(36,15,39),(36,27,45),(40,9,41),(40,30,50),(42,40,58),(44,33,55),(45,24,51),(45,28,53),(48,14,50),(48,20,52),(48,36,60),(52,39,65),(55,48,73),(56,33,65),(56,42,70),(60,11,61),(60,25,65),(60,32,68),(60,45,75),(63,16,65),(63,60,87),(64,48,80),(68,51,85),(70,24,74),(72,21,75),(72,30,78),(72,54,90),(72,65,97),(75,40,85),(76,57,95),(77,36,85),(80,18,82),(80,39,89),(80,60,100),(84,13,85),(84,35,91),(96,28,100)]
λ>
#!/bin/sh
ghci \
-package-db /_path_/.cabal-sandbox/x86_64-osx-ghc-7.10.2-packages.conf.d/ \
-XNoImplicitPrelude \
-XTypeFamilies \
-XConstraintKinds \
-XDataKinds \
-XGADTs \
-XTypeOperators \