Skip to content

Instantly share code, notes, and snippets.

View dalaing's full-sized avatar

Dave Laing dalaing

  • Brisbane, Australia
View GitHub Profile
@dalaing
dalaing / Pair.hs
Last active March 5, 2018 03:28
Covariant and Contravariant
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE GADTs #-}
module Ops where
import Control.Applicative
import GHC.Generics
import Data.Void
@dalaing
dalaing / Scratch.hs
Last active March 7, 2018 08:25
Contravariant EOT
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE GADTs #-}
module Ops where
import Data.Void
import Data.Functor.Contravariant
import Data.Functor.Contravariant.Divisible hiding (lost)
import Generics.Eot
Title:
A tasting plate of nifty things from the land of functional programming.
Abstract:
There are plenty of talks that introduce the basics of functional programming, and there are quite a few talks that try to explain some complex conceptual or theoretical piece of the puzzle.
This is not either of those talks. Instead, we'll be taking a series of shallow dives into a handful of libraries and tools in the functional programming space that are particular good at getting people excited.
The main theme will be showing off the nice things you can unearth if you have a community of motivated and curious folks from a lot of different domains and have them dig in a lot of different directions.
nixpkgs.config.packageOverrides = super: {
hydra = super.hydra.overrideDerivation (old : {
version = "2017-09-14";
src = pkgs.fetchFromGitHub {
owner = "NixOS";
repo = "hydra";
rev = "b828224fee451ad26e87cfe4eeb9c0704ee1062b";
sha256 = "05xv10ldsa1rahxbbgh5kwvl1dv4yvc8idczpifgb55fgqj8zazm";
};
});
scroller :: (MonadWidget t m, PerformEvent t m, MonadIO (Performable m), DomBuilder t m, DomBuilderSpace m ~ GhcjsDomSpace) => T.Text -> m (Event t ()) -> m ()
scroller height content = do
let
m = M.fromList [
("class", "list-group")
, ("style", T.concat ["position : relative; height : ", height, "; overflow : auto; "])
]
(s, e) <- elAttr' "div" m $ do
content
def writeFile(filename, contents):
with open(filename, "w") as f:
f.write(contents)
def readFile(filename):
contents = ""
with open(filename, "r") as f:
contents = f.read()
return contents
@dalaing
dalaing / blog-updater.nix
Created February 3, 2018 02:31
Hail example
{ config, pkgs, lib ? pkgs.lib, ... }:
with lib;
let
cfg = config.services.blog-updater;
in
{
# interface
options = {
@dalaing
dalaing / Demo.hs
Created January 18, 2018 12:18
Bound Demo
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE StandaloneDeriving #-}
module Demo where
@dalaing
dalaing / Test.hs
Last active January 3, 2018 00:57
trackLines :: (Reflex t, MonadHold t m)
=> Event t Point
-> Event t Point
-> Event t Point
-> m (Behavior t [Maybe Point])
trackLines eUp eDown eMove = do
-- track whether the mouse is up or down in a Behavior
bState <- hold False . leftmost $ [
False <$ eUp
Error (figuring out linker information): user error (invalid --version output, or linker is unsupported)
<no location info>: error:
Warning: Couldn't figure out linker information!
Make sure you're using GNU ld, GNU gold or the built in OS X linker, etc.
*** Linker:
/nix/store/xzhv124j2cp9h7wk2p5c6syz3myj1jrh-wasm32-unknown-unknown-wasm-clang-cross-wrapper/bin/wasm32-unknown-unknown-wasm-cc -fno-stack-protector -DNO_REGS -DUSE_MINIINTERPRETER -o ../test -lm -no-pie ../Main.o -L/home/dave/work/github.com/WebGHC/ghc/libraries/base/dist-install/build -L/home/dave/work/github.com/WebGHC/ghc/libraries/integer-simple/dist-install/build -L/home/dave/work/github.com/WebGHC/ghc/libraries/ghc-prim/dist-install/build -L/home/dave/work/github.com/WebGHC/wasm-cross/ghc/rts/dist/build /run/user/1000/ghc5661_0/ghc_2.o -Wl,-allow-undefined-file,rts.wasm.syms -lHSbase-4.11.0.0 -lHSinteger-simple-0.1.1.1 -lHSghc-prim-0.5.2.0 -liconv -lm -lrt -ldl
clang-6.0: warning: argument unused during compilation: '-nopie