Skip to content

Instantly share code, notes, and snippets.

View greydot's full-sized avatar
🐵
returning to monke

<[0_o]> greydot

🐵
returning to monke
View GitHub Profile
@greydot
greydot / hls-wrapper.sh
Last active June 9, 2020 13:49
Wraps around Haskell LSP servers and runs one in nix-shell if available. Requires yq if hie.yaml is present.
#!/usr/bin/env bash
SERVERS=( haskell-language-server-wrapper hie-wrapper haskell-language-server hie ghcide )
SERVER=
SERVER_PATH=
NIX_FILES=( shell.nix default.nix nix/shell.nix nix/default.nix )
NIX_CMD=
@greydot
greydot / e.hs
Created February 25, 2020 09:17
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
import Data.Proxy
import Unsafe.Coerce
class KnownBool (b :: Bool) where
{-# LANGUAGE ScopedTypeVariables #-}
import Data.IP
import Data.IP.RouteTable (IPRTable)
import qualified Data.IP.RouteTable as RT
import System.Environment (getArgs)
main :: IO ()
main = do [path] <- getArgs
nets <- map read . lines <$> readFile path
let rt :: IPRTable IPv4 () = RT.fromList $ zip nets (repeat ())
@greydot
greydot / MonadControlGHC8.hs
Created October 13, 2016 00:50 — forked from brendanhay/MonadControlGHC8.hs
GHC8 ImpredictiveTypes + monad-control instances
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module MonadControlGHC8 where
import Control.Applicative (Alternative, Applicative)
import Control.Monad.Base (MonadBase)
import Control.Monad.Reader (MonadReader, ReaderT)
@greydot
greydot / fork.hs
Created May 29, 2016 19:57
Segfaults somewhere between 500 and 1000 iterations.
import Control.Monad (when)
import System.Exit (exitSuccess)
import System.Posix.Process (forkProcess)
fork_ :: Integer -> IO ()
fork_ n | n > 0 = do pid <- forkProcess (fork_ $ n - 1)
when (pid /= 0) exitSuccess
| otherwise = putStrLn "I'm done!"
main :: IO ()