link to the video
original essay
- Write in past tense so you don’t have to re-edit when mailing
let | |
pkgs = import <nixpkgs> {}; | |
lib = pkgs.lib; | |
allOptions = (import <nixpkgs/nixos> {}).options; | |
# ** some helpers | |
# Like mapAttrs, but if `null` is returned from the mapping function, | |
# the element is removed from the attrset. | |
# |
module Abc (jsonWith') where | |
import Data.Aeson hiding (Value (..)) | |
import Data.Aeson.Key qualified as Key | |
import Data.Aeson.KeyMap qualified as KM | |
import Data.Aeson.Parser.Internal hiding (jsonWith') | |
import Data.Attoparsec.ByteString qualified as A | |
import Data.Attoparsec.ByteString.Char8 (Parser, char, string) | |
import Data.Function (fix) | |
import Data.Functor (($>)) |
module Postgres.Decoder where | |
import Control.Applicative (Alternative) | |
import Data.Aeson qualified as Json | |
import Data.Aeson.BetterErrors qualified as Json | |
import Data.Error.Tree | |
import Data.Typeable (Typeable) | |
import Database.PostgreSQL.Simple.FromField qualified as PG | |
import Database.PostgreSQL.Simple.FromRow qualified as PG | |
import Json qualified |
link to the video
original essay
#!/usr/bin/env python3 | |
# Small wrapper around nix-instantiate and `nix-store --realize` | |
# that checks whether the output path is already in a cache | |
# and if it isn’t, builds it. | |
# | |
# The arguments you pass will be given to nix-instantiate, | |
# not to nix-store --realize | |
# (This might be a TODO for the future). |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE DerivingStrategies #-} | |
{-# LANGUAGE LambdaCase #-} | |
module Label | |
( -- * Labels | |
Label, | |
label, | |
label', | |
getLabel, |
-- | Implement this class if you want your type to only implement the part of 'Num' | |
-- that allows creating them from Integer-literals, then derive Num via 'NumLiteralOnly': | |
-- | |
-- @ | |
-- data Foo = Foo Integer | |
-- deriving (Num) via (NumLiteralOnly "Foo" Foo) | |
-- | |
-- instance IntegerLiteral Foo where | |
-- integerLiteral i = Foo i | |
-- @ |
{-# LANGUAGE AllowAmbiguousTypes #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE QuasiQuotes #-} | |
module Json.Enc where | |
import Data.Aeson (Encoding, Value (..)) | |
import Data.Aeson.Encoding qualified as AesonEnc | |
import Data.Aeson.Key qualified as Key |
# the github message format requires newlines to be escaped with the URL-style %0A | |
# see https://github.com/actions/toolkit/issues/193#issuecomment-605394935 | |
def escapeNewline: gsub("[\\n]"; "%0A"); | |
# depending on the hlint message, we want to display the | |
# headings and the bodies differently | |
def prepareTitle: | |
if .hint == "Unused LANGUAGE pragma" | |
then { heading: "Unused LANGUAGE pragma: \(.from)" | |
, suggestion: "" |
{-# LANGUAGE ImportQualifiedPost #-} | |
{-# LANGUAGE DerivingVia #-} | |
module Main where | |
import Control.Foldl (Fold) | |
import Control.Foldl qualified as Fold | |
import Data.Function ((&)) | |
import Data.Profunctor | |
import Data.Semigroup |