Skip to content

Instantly share code, notes, and snippets.

with (import <nixpkgs> {}).pkgs;
with import <nixpkgs/pkgs/development/haskell-modules/lib.nix> { inherit pkgs; };
let
QuickCheck = haskellPackages.QuickCheck_2_9_2;
quickcheck-io = haskellPackages.quickcheck-io.override { inherit QuickCheck; };
quickcheck-instances = haskellPackages.quickcheck-instances.override { inherit QuickCheck; };
hspec-meta = haskellPackages.hspec-meta.override { inherit QuickCheck quickcheck-io;};
hspec-core = haskellPackages.hspec-core.override { inherit QuickCheck quickcheck-io hspec-meta;};
hspec = haskellPackages.hspec.override { inherit QuickCheck hspec-core hspec-meta; };
http-api-data = (doJailbreak haskellPackages.http-api-data_0_3_1).override {inherit QuickCheck hspec quickcheck-instances; };

Multi user nix installation

Each section should be run as the user or as root, pay attention to which one!

Install nix single user

As $USER

curl https://nixos.org/nix/install | sh
@Teggy
Teggy / four-solutions-to-a-trivial-problem.hs
Last active September 4, 2024 17:59
A Haskell "transcript" of Guy Steele's talk "Four Solutions to a Trivial Problem" (https://www.youtube.com/watch?v=ftcIcn8AmSY)
{-# LANGUAGE TypeSynonymInstances #-}
import Data.Monoid
import Data.Maybe
-- How much water does a "histogram" hold?
--
-- Inspired by Guy Steele's talk "Four Solutions to a Trivial Problem"
-- https://www.youtube.com/watch?v=ftcIcn8AmSY
{-# LANGUAGE OverloadedStrings, BangPatterns #-}
module Main (main) where
import Criterion.Main
import Control.Applicative
import Data.Attoparsec.ByteString as P
import Data.Attoparsec.ByteString.Char8 (char8, endOfLine, isDigit_w8)
import Data.ByteString (ByteString)
import Data.Word (Word8)
@fritzy
fritzy / 1_triggers.sql
Last active April 7, 2024 20:07
Get table change notifications from Postgres as JSON
CREATE OR REPLACE FUNCTION table_update_notify() RETURNS trigger AS $$
DECLARE
id bigint;
BEGIN
IF TG_OP = 'INSERT' OR TG_OP = 'UPDATE' THEN
id = NEW.id;
ELSE
id = OLD.id;
END IF;
PERFORM pg_notify('table_update', json_build_object('table', TG_TABLE_NAME, 'id', id, 'type', TG_OP)::text);
> import Control.Monad.Trans
> import Control.Monad.Trans.Iter
The completely iterative free monad transformer lets us capture non-termination as an effect. Furthermore, it's a monad *transformer*, so we can add non-termination on top of other effects.
A convenient combinator is
> untilSuccess :: Monad m => m (Maybe a) -> IterT m a
> untilSuccess f = maybe (delay (untilSuccess f)) return =<< lift f
@chrisdone
chrisdone / typing.md
Last active August 18, 2024 09:54
Typing Haskell in Haskell

Typing Haskell in Haskell

MARK P. JONES

Pacific Software Research Center

Department of Computer Science and Engineering

Oregon Graduate Institute of Science and Technology

@dmalikov
dmalikov / README.markdown
Last active May 31, 2019 06:31
Nix / NixOS links

Various blog posts related to Nix and NixOS


General