Skip to content

Instantly share code, notes, and snippets.

Chris Done chrisdone

Block or report user

Report or block chrisdone

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View out.json
{
"packages": [
{
"components": [
{
"modules": [
{
"path": "/home/chris/Work/fpco/stack/src/Control/Concurrent/Execute.hs",
"name": "Control.Concurrent.Execute"
},
@chrisdone
chrisdone / Lexx.hs
Last active Jan 14, 2020
Lexx - Show printer
View Lexx.hs
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
-- | Show instance lexer and pretty-printer.
module Lexx where
import Control.Monad.State
@chrisdone
chrisdone / 0README.md
Last active Dec 27, 2019
Build kafka docs
View 0README.md
View differ-example.js
<script src="templates/diffDOM.js"></script>
<script>
var before = document.createElement('div');
before.innerHTML = "<p>Hello, World!: 1</p><input type='text'>";
before.childNodes[1].value = "Hello, World!"
console.log('Output: %o', before.childNodes[1].value);
var after = document.createElement('div');
after.innerHTML = "<p>Hello, World: 2</p><input type='text'><p>Whassup?</p>";
@chrisdone
chrisdone / DBAPI.hs
Last active Jan 18, 2020
Defaulting fields in a record in Haskell
View DBAPI.hs
{-# LANGUAGE DataKinds #-}
-- | My database API.
module DBAPI where
import Data.Defaults
data ConnSpec p = ConnSpec
{ username :: !(Required p String)
@chrisdone
chrisdone / process-ffi-proposal.md
Last active Dec 1, 2019
Proposal: Foreign Function Interface for Processes
View process-ffi-proposal.md

Proposal: Foreign Function Interface for Processes

Background

Thread with some poorly put together thoughts.

Limitations of Process Arguments

  • Finite: All inputs to a program are finite. In every mainstream OS, arguments are a string of limited size. They are not
@chrisdone
chrisdone / build.Dockerfile
Last active Nov 29, 2019
Testing stack master
View build.Dockerfile
FROM debian:9-slim
MAINTAINER Chris Done
################################################################################
# Haskell system dependencies (basically never changes)
RUN apt-get update && \
apt-get install -yq --no-install-suggests --no-install-recommends --force-yes -y -qq \
netbase git ca-certificates xz-utils build-essential curl unzip libgmp-dev
View texp-num.hs
instance Num a => Num (Q (TExp (SomeNamedWith IsNonzero a))) where
fromInteger 0 = error "It's zero, fool!"
fromInteger n = [|| someNamedWith IsNonzero (fromInteger n) ||]
fine :: Double
fine =
case $$(1) :: SomeNamedWith IsNonzero Double of
(SomeNamedWith p divisor) ->
divide p 123 divisor
@chrisdone
chrisdone / Intro.md
Last active Nov 20, 2019
Statically checked overloaded strings
View Intro.md

Statically checked overloaded strings

This gist demonstrates a trick I came up with which is defining IsString for Q (TExp a), where a is lift-able. This allows you to write $$("...") and have the string parsed at compile-time.

This offers a light-weight way to enforce compile-time constraints. It's basically OverloadedStrings with static checks.

This trick works already in existing (old) GHCs.

View ghc-ffi-types.hs
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_powm_word" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Word# #))
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_powm" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Int# #))
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_powm1" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Word# #))
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_powm_sec" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Int# #))
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_invert_word" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Word# #))
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_invert" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Int# #))
(CCall (CCallSpec (StaticTarget NoSourceText "__int_encodeDouble" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Double# #))
(CCall (CCallSpec
You can’t perform that action at this time.