Skip to content

Instantly share code, notes, and snippets.

@tfausak
tfausak / DisableWarnings.hs
Last active May 24, 2022
A GHC plugin for disabling some warnings.
View DisableWarnings.hs
module DisableWarnings where
import qualified Data.List as List
import qualified GHC.Data.Bag as Bag
import qualified GHC.Data.IOEnv as IOEnv
import qualified GHC.Plugins as Plugins
import qualified GHC.Tc.Types as Tc
import qualified GHC.Types.Error as Error
plugin :: Plugins.Plugin
View brittany-benchmark.hs
#! /usr/bin/env sh
set -o errexit
# https://github.com/haskell-servant/servant/issues/986
###############################################################################
# Print out various system information.
date
lsb_release --all
@tfausak
tfausak / HW_Answer.hs
Last active Nov 17, 2021
2021 State of Haskell Survey Results
View HW_Answer.hs
module HW_Answer where
import qualified Data.Text as Text
import qualified Data.Vector as Vector
import qualified HW_Other as Other
data Answer
= Single (Vector.Vector Text.Text)
| Multi Other.Other (Vector.Vector Text.Text)
| Extension (Vector.Vector Text.Text)
@tfausak
tfausak / select-list-or-source.hs
Created Nov 8, 2021
Persistent's `selectList` versus `selectSource` in Haskell with PostgreSQL.
View select-list-or-source.hs
{-# language DataKinds #-}
{-# language DerivingStrategies #-}
{-# language EmptyDataDecls #-}
{-# language FlexibleInstances #-}
{-# language GADTs #-}
{-# language GeneralizedNewtypeDeriving #-}
{-# language MultiParamTypeClasses #-}
{-# language OverloadedStrings #-}
{-# language QuasiQuotes #-}
{-# language StandaloneDeriving #-}
View Main.hs
import qualified Control.DeepSeq as DeepSeq
import qualified Control.Exception as Exception
import qualified Data.HashMap.Strict as HashMap
import qualified Data.HashMap.Strict.InsOrd as InsOrd
import qualified Data.Map.Lazy as Map.Lazy
import qualified Data.Map.Strict as Map.Strict
import qualified Data.Text as Text
import qualified Data.Vector as Vector
import qualified Gauge
import qualified Z.Data.Vector as ZVector
@tfausak
tfausak / DerivingViaPlugin.hs
Last active Aug 23, 2021
Cursed Haskell: Deriving via plugin
View DerivingViaPlugin.hs
-- https://downloads.haskell.org/~ghc/9.0.1/docs/html/users_guide/extending_ghc.html#compiler-plugins
-- https://downloads.haskell.org/~ghc/9.0.1/docs/html/libraries/ghc-9.0.1/GHC-Plugins.html
module DerivingViaPlugin where
import qualified Control.Monad as Monad
import qualified GHC.Data.Bag as G
import qualified GHC.Hs as G
import qualified GHC.Plugins as P
import qualified GHC.Types.Basic as G
@tfausak
tfausak / Main.hs
Last active Aug 7, 2021
Example of unexpected ambiguity.
View Main.hs
#! /usr/bin/env stack
-- stack --resolver ghc-9.0.1 script
-- https://github.com/tfausak/witch/issues/19
{-# language AllowAmbiguousTypes #-}
{-# language ScopedTypeVariables #-}
{-# language TypeApplications #-}
{-# language TypeFamilies #-}
@tfausak
tfausak / Dockerfile
Last active Aug 7, 2021
Exhibits a libpq bug.
View Dockerfile
FROM haskell:8.10
RUN apt-get update && apt-get install --yes libpq-dev
ARG USER=haskell
RUN useradd --create-home "$USER"
USER $USER
View mongo-batch-performance.hs
#! /usr/bin/env stack
-- stack --resolver lts-17.0 script
{-# language OverloadedStrings #-}
import qualified Control.Exception as Exception
import qualified Control.Monad as Monad
import qualified Data.Function as Function
import qualified Data.IORef as IORef
import qualified Database.MongoDB as Mongo
import qualified Data.Text as Text
import qualified GHC.Clock as Clock
View itoa.hs
{-
benchmarked show
time 18.81 ns (18.78 ns .. 18.85 ns)
1.000 R² (1.000 R² .. 1.000 R²)
mean 18.80 ns (18.79 ns .. 18.82 ns)
std dev 41.27 ps (27.30 ps .. 70.30 ps)
benchmarked printf
time 338.0 ns (334.5 ns .. 341.2 ns)
0.999 R² (0.999 R² .. 1.000 R²)