Skip to content

Instantly share code, notes, and snippets.

View heath's full-sized avatar
❄️
λΠ

heath

❄️
λΠ
View GitHub Profile
@brucebentley
brucebentley / install-asdf.sh
Last active November 28, 2023 22:02
Example script to install ASDF along with some common plugins & their latest versions.
#!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Update Homebrew:
# - - - - - - - - - - - - - - - - - - - - - - - - -
brew update
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Install asdf dependencies:
# - - - - - - - - - - - - - - - - - - - - - - - - -
@monadplus
monadplus / running-haskell-scripts.md
Last active February 10, 2023 19:46
Running a haskell script without GHC using nix

Updated version can be found on my website.

Running a haskell script without GHC

Given the following haskell script generate-random-samples.hs that requires mwc-random ...

{-# LANGUAGE ScopedTypeVariables #-}

import System.Random.MWC
@graninas
graninas / haskell_approaches_comparison_table.md
Last active April 25, 2024 20:49
Haskell Approaches Comparison Table

An Opinionated Comparison of Software Design Approaches in Haskell

| | Raw IO | Free Monads; Church Encoded Free Monads | Final Tagless / mtl | Effect Systems | ReaderT

@gelisam
gelisam / TestingCFromHaskell.hs
Last active February 17, 2020 05:03
using Haskell's QuickCheck to property-test C's qsort
-- in response to https://www.reddit.com/r/haskell/comments/duopq8/create_tests_for_other_languages_using_haskell/
-- TLDR: yes, you can test C functions from Haskell; it's a bit painful to
-- call C from Haskell, but once you do, testing is the easy part!
{-# LANGUAGE QuasiQuotes, ScopedTypeVariables, TemplateHaskell #-}
module Main where
import Data.Foldable (for_)
import Data.Traversable (for)
import Foreign.C.Types (CInt, CSize)
fmap :: ... => (a -> b) -> (f a -> f b)
(.) :: (y -> z) -> (x -> y) -> (x -> z)
fmap :: (f2 a -> f2 b) -> (f1 (f2 a) -> f1 (f2 b))
fmap :: (a -> b) -> (f2 a -> f2 b)
(.) :: (y -> z ) -> (x -> y ) -> (x -> z )
(.) :: ((f2 a -> f2 b) -> (f1 (f2 a) -> f1 (f2 b))) -> ((a -> b) -> (f2 a -> f2 b)) -> ((a -> b) -> (f1 (f2 a) -> f1 (f2 a)))
(.) fmap fmap :: (a -> b) -> (f1 (f2 a) -> f1 (f2 b))
^--- (.) fmap fmap = fmap . fmap
@dherman
dherman / fgrep.md
Last active August 29, 2015 14:16
fgrep: a style/expressiveness test for stream libraries

How Would You Write fgrep?

This is a little style and expressiveness test for various stream libraries. It is certainly not a proof of anything, so much as an ability to showcase how some basic features of streams fit together with different libraries.

Problem statement: given a library of streams, implement an API analogous to fgrep, i.e., a literal string grepper.

Specifically, implement a function fgrep(test, filenames[, limit=10]), which takes a source string, a list of filenames, and an optional concurrency limit, and produces a stream of Match records { filename: string, lineNumber: number, line: string }, representing all lines of all files that contain the string test. For each matching record, filename is the name of the file where the match was found, lineNumber is the one-indexed line number where the match was found, and line is the contents of the line where the match was found.

The limit argument indicates the maximum number of concurrent filehandles that should b

@paf31
paf31 / 24days.md
Last active August 8, 2023 05:53
24 Days of PureScript

This blog post series has moved here.

You might also be interested in the 2016 version.

@rob-brown
rob-brown / life.ex
Last active August 29, 2015 14:09
Conway's Game of Life
defmodule Life do
# Defaults to B3/S23
defstruct cells: [[]], born: [3], stays: [2, 3], width: 10, height: 10, step: 0
def run(file) do
file |> read_file |> loop
end
def loop(life) do
anonymous
anonymous / molepeople.md
Created November 7, 2014 22:46

thorium eating mole people

The basic problem of maintaining a civilization, according to Tainter, is maintaining a positive energy balance; spending less energy than it consumes. With a negative energy balance, gradually the entire population starves to death. For this reason, all historical human populations have lived on the surface of the Earth, not inside it, because on the surface there is lots of readily available sun energy, and even inefficient ways of harvesting it (such as plants) suffice to support humans. Also, the conditions are relatively mild. The worst problem is that parts of the surface do not have salt water covering them, which is a problem we learned to cope with some hundreds of millions of years ago, with means duch as lungs, eggs, and amniotic sacs. Inside the Earth, all of our necessities must be provided by clever contrivances; not just food, but light, oxygen, low pressure, cool, dry (we have become accustomed to it in the last few hundred million years) , and sanitation.

The