Skip to content

Instantly share code, notes, and snippets.

@tfausak
tfausak / Witch.hs
Last active November 6, 2024 17:46
Deriving `From` instances using `Generically`. https://github.com/tfausak/witch/issues/107
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
@tfausak
tfausak / UUIDv7.hs
Last active August 21, 2024 14:11
UUID v7 generator in Haskell.
#! /usr/bin/env cabal
{- cabal:
build-depends:
base,
bytestring,
entropy,
tasty-bench,
time,
uuid,
ghc-options:
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)
{
"customizations": {
"vscode": {
"extensions": [
"haskell.haskell"
]
}
},
"dockerComposeFile": "compose.yaml",
"service": "devcontainer",
@tfausak
tfausak / DisableWarnings.hs
Last active May 24, 2022 12:11
A GHC plugin for disabling some warnings.
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
#! /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 November 17, 2021 13:57
2021 State of Haskell Survey Results
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 November 8, 2021 20:36
Persistent's `selectList` versus `selectSource` in Haskell with PostgreSQL.
{-# language DataKinds #-}
{-# language DerivingStrategies #-}
{-# language EmptyDataDecls #-}
{-# language FlexibleInstances #-}
{-# language GADTs #-}
{-# language GeneralizedNewtypeDeriving #-}
{-# language MultiParamTypeClasses #-}
{-# language OverloadedStrings #-}
{-# language QuasiQuotes #-}
{-# language StandaloneDeriving #-}
@tfausak
tfausak / Main.hs
Last active September 18, 2021 14:26
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 August 23, 2021 14:13
Cursed Haskell: Deriving via plugin
-- 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