Skip to content

Instantly share code, notes, and snippets.

@ttuegel
ttuegel / StrictDeriving.hs
Created August 8, 2021 14:56
Unexpected behavior with Strict + DeriveFunctor
{-# LANGUAGE Strict #-}
{-# LANGUAGE DeriveFunctor #-}
module StrictDeriving where
newtype Id1 a = Id1 a
deriving (Functor, Show)
-- >>> fmap (const 2 . const undefined) (Id1 1)
-- Id1 2
@ttuegel
ttuegel / Bool.hs
Created February 13, 2019 17:07
Bool.hs
test_binaryTrees :: TestTree
test_binaryTrees =
testGroup "Combinations with operators that produce top or bottom"
[ mkEquals_ internalTrue internalFalse `becomes` bottom
, mkEquals_ internalFalse internalTrue `becomes` bottom
, mkEquals_ internalTrue internalTrue `becomes` (pure internalTrue)
, mkEquals_ internalFalse internalFalse `becomes` (pure internalFalse)
, mkAnd internalTrue internalFalse `becomes` bottom
, mkAnd internalFalse internalTrue `becomes` bottom
% Or Simplification
== Header
\begin{code}
{-|
Module : Kore.Step.Simplification.Or
Description : Tools for Or pattern simplification.
Copyright : (c) Runtime Verification, 2018
License : NCSA
@ttuegel
ttuegel / LazyPattern.hs
Created January 4, 2018 21:13
What does lazy pattern matching do?
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ViewPatterns #-}
module LazyPattern where
import Debug.Trace (trace)
data Foo a = Foo a
deriving (Show)

Keybase proof

I hereby claim:

  • I am ttuegel on github.
  • I am ttuegel (https://keybase.io/ttuegel) on keybase.
  • I have a public key ASASqOcv7gWaWVi7ZqerjxQEI_mRVcIUpDSWmyvineWJjgo

To claim this, I am signing this object:

@ttuegel
ttuegel / haskell-mode-indent.md
Last active February 15, 2016 23:06
Indentation pains in haskell-mode for Emacs

Electric indentation for parentheses, brackets, braces, commas, semicolons...

This isn't an issue of what I want, but rather when I want it. haskell-mode knows how to indent these things correctly, but I had to turn off electric indentation in haskell-mode because it does stupid things the rest of the time.

Concretely, I want a haskell-mode that knows how to be electric when there's only one "right" choice and that doesn't do stupid things when there are multiple possibilities.

@ttuegel
ttuegel / patchelf.nix
Created September 13, 2015 17:50
patchelf.nix
with (import <nixpkgs> {}).pkgs;
stdenv.mkDerivation rec {
name = "patchelf-0.9-pre";
src = fetchgit {
url = https://github.com/NixOS/patchelf.git;
rev = "63296c4e18381216f740670916608f9ef159672e";
sha256 = "b6b2b4891773ea9d36f1891082812a157b7a6097827594419fe4a4343aa403a1";
};
{ stdenv, fetchFromGitHub, cmake
, wayland, pixman, libxkbcommon, udev, libinput
, libX11, libxcb, x11
, mesa #nvidia_x11
, dbus, systemd
}:
let srcs = {
wlc = fetchFromGitHub {
owner = "Cloudef";
@ttuegel
ttuegel / gist:9a3be681985fc5837a38
Created January 24, 2015 00:09
Function application versus evaluation
ghci> import Control.Monad (liftM)
ghci> :t liftM
liftM :: Monad m => (a1 -> r) -> m a1 -> m r
ghci> import Debug.Trace (trace)
ghci> liftM (\x -> trace "function applied" (x + 3)) [1 :: Int, 2, 3]
[function applied
4,function applied
5,function applied
6]
ghci> liftM (trace "function evaluated" (+ 3)) [1 :: Int, 2, 3]
@ttuegel
ttuegel / gist:374df60a067a254e375f
Created November 18, 2014 19:21
.Xresources or .Xdefaults settings for FreeType
Xft.dpi: 96
Xft.antialias: 1
Xft.rgba: rgb
Xft.hinting: 1
Xft.hintstyle: hintslight
Xft.lcdfilter: lcddefault
Xft.autohint: 0