Skip to content

Instantly share code, notes, and snippets.

@chrisdone
chrisdone / FlushSource.hs
Last active Feb 6, 2020
Flushing source conduit
View FlushSource.hs
{-# LANGUAGE LambdaCase #-}
-- | Sources that flush when their monadic action takes longer than n
-- microseconds.
module Data.Conduit.Flush where
import Data.Conduit
import Data.Conduit.Internal as Pipe (ConduitT(..), Pipe(..))
import UnliftIO
View Resource.hs
{-# LANGUAGE ScopedTypeVariables #-}
-- | A ResourceT-based way to use connections with conduit.
module Data.Conduit.Network.Resource where
import qualified Network.Socket as NS
import Control.Exception
import Control.Monad.IO.Class
import Control.Monad.Trans.Resource
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 Dec 3, 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
You can’t perform that action at this time.