Skip to content

Instantly share code, notes, and snippets.

View Main.hs
#! /usr/bin/env stack
-- stack --resolver ghc-9.0.1 script
{-# language AllowAmbiguousTypes #-}
{-# language ScopedTypeVariables #-}
{-# language TypeApplications #-}
{-# language TypeFamilies #-}
data Break
type family Ambiguous a where
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²)
@tfausak
tfausak / stack.yaml
Created Dec 31, 2020
GHC 9.0.1 RC1
View stack.yaml
# The GHC team announced the first release candidate for the 9.0.1 release of
# GHC: https://discourse.haskell.org/t/glasgow-haskell-compiler-9-0-1-rc1-now-available/1706
#
# This is an example `stack.yaml` file that you can use to try out the release
# candidate. Save this file in your current directory and run `stack setup`.
# After that you should be able to use Stack as normal, including
# `stack exec ghci` and `stack build`.
#
# If for whatever reason you don't want to use Stack, you can download the
# official release tarballs at: https://downloads.haskell.org/ghc/9.0.1-rc1/
View aoc-2020-15-2.hs
import qualified Data.IntMap as IntMap
import qualified Data.List as List
import qualified Data.Maybe as Maybe
import qualified Data.Ord as Ord
import qualified Data.Text as Text
main = do
print limit
interact
$ show
@tfausak
tfausak / Main.hs
Created Nov 22, 2020
2020 State of Haskell Survey
View Main.hs
{-# language OverloadedStrings #-}
module Main ( main ) where
import qualified Control.Monad as Monad
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.Encode.Pretty as Aeson
import qualified Data.Aeson.Types as Aeson
import qualified Data.Bifunctor as Bifunctor
import qualified Data.ByteString.Lazy as LazyByteString
import qualified Data.Csv as Csv
import qualified Data.HashMap.Strict as HashMap
@tfausak
tfausak / language-extension-examples.hs
Created Aug 1, 2020
Minimal examples of Haskell language extensions.
View language-extension-examples.hs
a = a :: Eq b => () -- AllowAmbiguousTypes
a = proc b -> id -< b -- Arrows
a = let !b = () in b -- BangPatterns
a = 0b0 -- BinaryLiterals
a = id do 0 -- BlockArguments
foreign import capi "" a :: ()
class A b where c :: Eq b => b -- ConstrainedClassMethods
type A = Eq -- ConstraintKinds
# -- CPP
import Data.Proxy; a = Proxy :: Proxy True -- DataKinds
View parse-with-ghc.hs
{-
this is a little experiment to parse a module with ghc
and extract exports identifiers, top-level declarations, and (documentation) comments
the idea is to use this as a basis for a haddock-like tool
that doesn't require type checking a module in order to run
-}
module Main ( main ) where
import qualified Control.Monad
import qualified DynFlags