Skip to content

Instantly share code, notes, and snippets.

View thoferon's full-sized avatar

Tom Feron thoferon

View GitHub Profile
import readline from "readline-sync"
// Side effects
class EffectfulImplementation {
getUserInput () {
return readline.question("> ")
}
listTodoItems () {
function numberField (key) {
return {
action: "numberField",
key,
}
}
function stringField (key) {
return {
action: "stringField",
import readline from "readline-sync"
function read () {
return {
action: "read",
next: pure,
}
}
function print (string) {
import _ from "underscore"
import game from "./sequentialActions.js"
function testInterpreter (program, inputs, accOutputs) {
switch (program.action) {
case "read":
const input = inputs[0]
const rest = inputs.slice(1)
return testInterpreter(program.next(input), rest, accOutputs)
@thoferon
thoferon / demo.cabal
Created February 4, 2020 06:14
haskell-nix-setup
cabal-version: 1.12
name: demo
version: 0.9.0
author: Tom Feron
maintainer: Tom Feron
build-type: Simple
library
hs-source-dirs: src
ghc-options: -Wall
@thoferon
thoferon / Module.hs
Created February 4, 2020 06:14
haskell-nix-setup
module Module
( secretNumber
) where
secretNumber :: Int
secretNumber = 4
@thoferon
thoferon / OtherModule.hs
Created February 4, 2020 06:15
haskell-nix-setup
module OtherModule
( secretString
) where
import Module
secretString :: String
secretString = show secretNumber
@thoferon
thoferon / Main.hs
Created February 4, 2020 06:15
haskell-nix-setup
import qualified Data.Text as T
import OtherModule
main :: IO ()
main = T.putStrLn (T.pack secretString)
@thoferon
thoferon / sources.nix
Created February 4, 2020 06:16
haskell-nix-setup
{
nixpkgs = builtins.fetchGit {
url = "https://github.com/NixOS/nixpkgs.git";
rev = "05626cc86b8a8bbadae7753d2e33661400ff67de";
};
}
@thoferon
thoferon / nixpkgs.nix
Created February 4, 2020 06:17
haskell-nix-setup
args@{ ... }:
let
sources = import ./sources.nix;
nixpkgs = import sources.nixpkgs (args // {
overlays = [
(import ./haskell/overlay.nix)
];
});