Skip to content

Instantly share code, notes, and snippets.

hardentoo / random_monad_example.hs
Created Jul 12, 2018 — forked from ijt/random_monad_example.hs
Example of how to use the Random monad in Haskell
View random_monad_example.hs
-- cabal install MonadRandom
-- ghc random_monad_example
-- ./random_monad_example
-- The code here is stolen from a comment in the MonadRandom source code.
import Control.Monad.Random
die :: RandomGen g => Rand g Int
die = getRandomR (1,6)
View STLC.agda
module STLC where
-- Simple substitution à la Conor, as described in
id : {A : Set} A A
id x = x
data Type : Set where
* : Type
_⇒_ : (S T : Type) Type
View STLC.agda
Dependently typed metaprogramming (in Agda)
Conor McBride, 2013
Dependently typed programming
Conor McBride, 2011
hardentoo / he-get.hs
Created Jun 11, 2018
A simple wget style program using Haskell and http-enumerator
View he-get.hs
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad.IO.Class (liftIO)
import Network (withSocketsDo)
import System.Environment (getArgs, getProgName)
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as LBS
import qualified Data.CaseInsensitive as CI
import qualified Network.HTTP.Enumerator as HE
hardentoo / new-gplv3-full-project.hsfiles
Created Jun 9, 2018 — forked from queertypes/new-gplv3-full-project.hsfiles
Haskell Stack template: GPL-3, doctests, hlint, many other goodies
View new-gplv3-full-project.hsfiles
{-# START_FILE {{name}}.cabal #-}
name: {{name}}
synopsis: Initial project template from stack
description: Please see
license: GPL-3
license-file: LICENSE
author: {{author-name}}{{^author-name}}Author name here{{/author-name}}
maintainer: {{author-email}}{{^author-email}}{{/author-email}}
copyright: {{copyright}}{{^copyright}}{{year}}{{^year}}2017{{/year}} {{author-name}}{{^author-name}}Author name here{{/author-name}}{{/copyright}}
hardentoo /
Created Jun 4, 2018 — forked from ralphbean/
Script to list all repos for a github organization
#!/usr/bin/env python
""" Print all of the clone-urls for a GitHub organization.
It requires the pygithub3 module, which you can install like this::
$ sudo yum -y install python-virtualenv
$ mkdir scratch
$ cd scratch
$ virtualenv my-virtualenv
hardentoo / histo-futu.hs
Created May 30, 2018 — forked from jtobin/histo-futu.hs
Time-traveling recursion schemes
View histo-futu.hs
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TypeFamilies #-}
import Control.Comonad.Cofree
import Control.Monad.Free
import Data.Functor.Foldable
oddIndices :: [a] -> [a]
oddIndices = histo $ \case
Nil -> []
hardentoo / InductiveConstraints.hs
Created May 30, 2018 — forked from nfrisby/InductiveConstraints.hs
simple demo of "proving" in Haskell via singleton types
View InductiveConstraints.hs
{-# LANGUAGE RankNTypes, TypeFamilies, DataKinds, TypeOperators,
ScopedTypeVariables, PolyKinds, ConstraintKinds, GADTs,
MultiParamTypeClasses, FlexibleInstances, UndecidableInstances,
FlexibleContexts #-}
module InductiveConstraints where
import GHC.Prim (Constraint)
hardentoo /
Created May 29, 2018 — forked from chrisdone/
stack hoogle

Introducing the stack hoogle feature!

With the release of hoogle5, we can now hoogle all local packages.

This let us implement stack hoogle, which is on the master branch of stack, but is not yet on a stack release. We'd like you to try it out before we do!

To upgrade to the latest stack from git, use:

hardentoo / SplayTree.hs
Created May 26, 2018 — forked from m2ym/SplayTree.hs
Toy Splay Tree in Haskell
View SplayTree.hs
import Data.Maybe (isJust)
data Tree a = Leaf | Node (Tree a) a (Tree a)
replace :: a -> Tree a -> Tree a
replace a Leaf = Node Leaf a Leaf
replace a (Node l _ r) = Node l a r
rotateR :: Tree a -> Tree a
rotateR (Node (Node x a y) b z) = Node x a (Node y b z)