Skip to content

Instantly share code, notes, and snippets.

import Pipes
import Pipes.HTTP
import qualified Pipes.Prelude as P
import qualified Pipes.ByteString as PB
import qualified Data.ByteString as BS
url = "https://typeclasses.com"
fetch url action =
do
{ pkgs, ... }:
let
src = pkgs.fetchFromGitHub {
owner = "cachix";
repo = "cachix";
# Jun 23, 2018
rev = "6a65632a4b51488b5355377e5c292a6a01efee2e";
sha256 = "13l12xkqpx6l7pfqwysz6yrgpjk6ydj6w7c85h74mzz4fvzihxyl";
};

The problem:

chris@cubby ~ ❯❯❯ nix run -f '<nixpkgs>' zlib -c cabal install zlib
Resolving dependencies...
Configuring zlib-0.6.2...
Failed to install zlib-0.6.2
Build log ( /home/chris/.cabal/logs/ghc-8.2.2/zlib-0.6.2-L2Qec9Buml21zwTs2VzSGb.log ):
cabal: Entering directory '/tmp/cabal-tmp-31070/zlib-0.6.2'
Configuring zlib-0.6.2...
#! /usr/bin/env bash
set -e # Exit immediately if a command exits with a non-zero status.
set -u # Treat unset variables as an error when substituting
# The .nix directory is where we put all our Nix output symlinks. Create it if it doesn't already exist.
mkdir --parents .nix
# Pin Nix to the exact version of nixpkgs we're using.
nix build -f nixpkgs.nix --out-link .nix/nixpkgs
isHex :: Word8 -> Bool
isHex w =
(w >= 48 && w <= 57) || -- '0' to '9'
(w >= 97 && w <= 102) || -- lower-case 'a' to 'f'
(w >= 65 && w <= 70) -- upper-case 'A' to 'F'
{-# LANGUAGE LambdaCase #-}
import Data.IORef
import Data.Map (Map)
import qualified Data.Map as Map
import Numeric.Natural
type Cache a b = IORef (Map a b)
newCache :: IO (Cache a b)
{-# LANGUAGE LambdaCase2 #-}
intToBool :: Int -> Maybe Bool
boolToInt :: Bool -> Int
(boolToInt, intToBool) =
\case2
False -> 0
True -> 1
-- | A string we're looking for in the source.
--
-- /Mnemonic: "needle in a haystack"/
newtype Needle = Needle Strict.Text
deriving Eq
-- | Needles are sorted by length with the longest needles first.
--
-- We use this ordering when performing replacements. For example, if both
-- "a" and "ab" are needles, then we give "ab" a chance to be found /before/
import qualified Data.Text as Strict (Text)
import qualified Data.Text as StrictText
import qualified Data.Text.Lazy as Lazy (Text)
import qualified Data.Text.Lazy as LazyText
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
module Wrap where
import Control.Arrow ((>>>))
import Data.Bool (not, (||))
import Data.Char (isSpace)
import Data.Function ((&))
import Data.Functor (fmap, ($>))