Skip to content

Instantly share code, notes, and snippets.

View ThoNohT's full-sized avatar

Eric Bataille ThoNohT

View GitHub Profile
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
import qualified Data.List as L
class Uncons l a where
@ThoNohT
ThoNohT / AsyncTailRec.fs
Last active September 8, 2022 11:11
Tail recursion and async
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Running
/// This function is recursive, but not tail recursive.
let rec countHigh (nr: int64) = if nr = 0L then 0L else countHigh (nr - 1L) + 1L
// This function is tail recursive.
let rec countHighTailRec (nr: int64) acc = if nr = 0L then acc else countHighTailRec (nr - 1L) (acc + 1L)
// This function is recursive in async, but not tail recursive.
@ThoNohT
ThoNohT / dehaskell.md
Last active April 24, 2024 23:30
Cleaning haskell packages from pacman

Cleaning up haskell packages on Arch Linux

In Arch Linux, all haskell packages are dynamically linked. This can be a headache for the user, since it results in a large amount of haskell-* packages being installed on your system, and the possibility for version conflicts. A way around this is to not depend on pacman at all for haskell packages, but manually install them. In this document I explain how I switched from a lot of haskell packages installed with pacman, to a few manually installed packages.

Finding packages to uninstall

To determine which packages to uninstall (and replace), a few tools are useful:

  • pacman itself
  • pacgraph
boolToString :: Bool -> String
boolToString True = "TRUE"
boolToString False = "FALSE"
assertString :: Eq a => a -> a -> Bool
assertString a b = a == b
infixr 8 |.|
(|.|) :: (b -> c) -> (a -> a' -> b) -> a -> a' -> c

Assuming you use XMonad.Util.EZConfig to configure your key mappings, this code allows you to print those mappings in a nice format and let them be visualized in multiple ways.

Starting from the latest darcs template xmonad.hs, but the key map configuration already replaced with XMonad.Util.EZConfig, I need the following imports extra imports:

import Data.Foldable
import qualified Data.List as L

This is the code containing the types used for formatting the input, and the actual formatting code.

using System;
using System.Text;
namespace Tree
{
class Program
{
static void Main(string[] args)
{
var h = 32;
@ThoNohT
ThoNohT / nohboard_version.json
Last active April 12, 2020 15:35
The NohBoard version
{
"Major": 1,
"Minor": 3,
"Patch": 0
}

Keybase proof

I hereby claim:

  • I am ThoNohT on github.
  • I am thonoht (https://keybase.io/thonoht) on keybase.
  • I have a public key whose fingerprint is 7AAA 4C85 DBE2 D032 2480 5E5D 3D81 E30A 57CD 4CD6

To claim this, I am signing this object: