This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:{ | |
let ghciTime cmd = do | |
let mkVar n u = "ghciTime_" ++ n ++ "_" ++ show (Data.Unique.hashUnique u) | |
startVar <- mkVar "start" <$> Data.Unique.newUnique | |
resVar <- mkVar "res" <$> Data.Unique.newUnique | |
endVar <- mkVar "end" <$> Data.Unique.newUnique | |
pure $ unlines | |
[ startVar ++ " <- Data.Time.getCurrentTime" | |
, resVar ++ "<- " ++ cmd | |
, endVar ++ " <- Data.Time.getCurrentTime" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE GADTs #-} | |
module HList.GADT where | |
import Data.Kind | |
data HList (ts :: [Type]) where | |
HNil :: HList '[] | |
HCons :: forall t ts. t -> HList ts -> HList (t ': ts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE LambdaCase #-} | |
import Data.Kind | |
data I a | |
data X a | |
data XX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:{ | |
let doTH code = do | |
u <- Data.Unique.newUnique | |
let decls = "ghciTH_" ++ show (Data.Unique.hashUnique u) | |
pure $ unlines | |
[ unwords ["let", decls, "=", code] | |
, "() = ();" ++ decls | |
] | |
:} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
concat(zipWith replicate [1,2,1,0] "cold") | |
-- Desugar string literal to [Char] | |
concat(zipWith replicate [1,2,1,0] ['c', 'o', 'l', 'd']) | |
-- https://hackage.haskell.org/package/base-4.19.0.0/docs/src/GHC.List.html#zipWith | |
-- Rewritten to not use the "go" helper, zipWith is: | |
-- zipWith f [] _ = [] | |
-- zipWith f _ [] = [] | |
-- zipWith f (x:xs) (y:ys) = f x y : zipWith f xs ys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"os/signal" | |
"sync/atomic" | |
"syscall" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dist-newstyle/* | |
.liquid/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Keep track of build times in a lightweight way | |
# The log file is based on branch name | |
function time-log-file() { | |
echo "$(time-log-dir)/time.$(git rev-parse --abbrev-ref HEAD | sed s#/#--#g).log" | |
} | |
function time-log-dir() { | |
echo "$(git rev-parse --show-toplevel)/.time-logs" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[armando@nixos:~]$ ghci | |
GHCi, version 9.2.8: https://www.haskell.org/ghc/ :? for help | |
Loaded GHCi configuration from /home/armando/.ghci | |
λ :seti -XDeriveGeneric | |
λ import GHC.Generics | |
λ data P = P Int Bool String deriving Generic | |
λ data S = S1 | S2 | S3 deriving Generic | |
λ data R = R { x :: Int, y :: Bool, z :: String } deriving Generic | |
λ data SR = S1 { x1 :: Int } | S2 { y2 :: Bool} | S3 { z3 :: String } deriving Generic | |
λ :t from |
NewerOlder