Skip to content

Instantly share code, notes, and snippets.

💭
trolling craigslist for free pallets

Chris Martin chris-martin

💭
trolling craigslist for free pallets
Block or report user

Report or block chris-martin

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 fib-memo.hs
{-# 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)
View case2.hs
{-# LANGUAGE LambdaCase2 #-}
intToBool :: Int -> Maybe Bool
boolToInt :: Bool -> Int
(boolToInt, intToBool) =
\case2
False -> 0
True -> 1
View Needle.hs
-- | 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/
View text-imports.hs
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
View wrap.hs
{-# 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, ($>))
View nix-deploy.bash
~/haskell/nix-deploy/result/bin/nix-deploy system \
--path (env NIXOS_CONFIG=$PWD/webserver1.nix nix-build '/home/chris/nix/path/unstable/nixos' -A system --no-out-link) \
--to chris@54.166.167.203 \
--switch
View nixos-font.nix
{
fonts.fonts = [
pkgs.corefonts
pkgs.fira
pkgs.fira-code
pkgs.fira-mono
pkgs.lato
pkgs.inconsolata
pkgs.symbola
pkgs.ubuntu_font_family
View web.nix
{
global-css = runCommand "style-global" { } ''
cat "${constants-scss}" "${./global.scss}" | "${sassc}/bin/sassc" > "$out"
'';
global-js = runCommand "script-global" { } ''
cat "${./global.js}" | ${minify}/bin/minify --type=js > "$out"
'';
}
View Bifunctor.hs
module Foo.Bifunctor
(
-- * These
These (..), these'fold, these'fst, these'snd
-- * TupleF
, TupleF (..), tupleF'fst, tupleF'snd
-- * TupleFirstF
, TupleFirstF (..), tupleFirstF'fst, tupleFirstF'snd
View lazy.md

Let's say we want to test whether the list [1,2,3,4,5] contains 2.

We could do this by turning the list of integers [1,2,3,4,5] into a list of Booleans [False, True, False, False, False] indicating, for each element in the original list, whether it is equal to 2.

λ> x = map (== 2) [1..5]
You can’t perform that action at this time.