This file contains hidden or 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 TemplateHaskell #-} | |
module Tasty.Runners.Buildkite.History where | |
import Tasty.Runners.Buildkite.Span ( Span ) | |
import Data.Aeson (defaultOptions, camelTo2) | |
import Data.Aeson.TH (deriveJSON, Options (fieldLabelModifier)) | |
data History = History { |
This file contains hidden or 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
rg "(withPackages *=)|(withPlugins *=)" --ignore-case --glob '*.nix' |
This file contains hidden or 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
fst = (a) -> (b) -> a | |
snd = (a) -> (b) -> b | |
_Pair2 = (a) -> (b) -> (p2) -> p2(a)(b) | |
show_pair = (p2) -> p2((a) -> (b) -> "(${a}, ${b})") | |
test_p2 = _Pair2('A')('B') | |
// (A, B) | |
println(show_pair(test_p2)) | |
// A | |
println(test_p2(fst)) |
This file contains hidden or 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 FlexibleInstances #-} | |
{-# LANGUAGE RankNTypes #-} | |
module Main where | |
import Prelude hiding (Maybe (..), concat, fst, head, snd, tail) | |
-- Church encoding of pair2s | |
newtype Pair2 a b | |
= MkPair2 |
This file contains hidden or 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
reverse :: [α] -> [α] | |
reverse as = foldr f id as [] | |
where | |
f :: α -- Element a to cons to as | |
-> ([α] -> β) -- Function f which operates on a list | |
-> [α] -- List as to prepend a to | |
-> β -- Result of applying function to a : as | |
f = flip (.) . (:) | |
-- Application |
This file contains hidden or 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
module Main where | |
import qualified Data.Foldable as Foldable | |
import Data.Map.Strict (Map) | |
import qualified Data.Map.Strict as Map | |
import Data.Set (Set) | |
-- Follow the path a value takes through multiple permutations. | |
-- If the value is not in the permutation, it is unchanged -- it is fixed. | |
trace :: Ord a => Map a a -> Map a a -> a -> a |
This file contains hidden or 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 RecordWildCards #-} | |
module Main where | |
data Solution = Solution | |
{ remainder :: Integer | |
, element :: Integer | |
, power :: Integer | |
} | |
instance Show Solution where |
This file contains hidden or 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
module Main where | |
// Generates a 2d list of zero-indexed indices of an nxn matrix. | |
twoDimIndices : {n} (fin n, 1 <= n) => [n][n](Integer, Integer) | |
twoDimIndices = [ [ (a,b) | a <- [0 .. n-1] ] | b <- [0 .. n-1] ] | |
// Transforms an n-bit array into a 2d nxn-bit array. | |
// The (i,j)-th element of the 2d nxn-bit array is the value of the i-th and | |
// j-th bits of the n-bit array XOR'd together. | |
gen : {n} (fin n, 2 <= n) => [n] -> [n * n] |
This file contains hidden or 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
module Main where | |
import Data.Bits | |
nonDiagIndices :: Int -> [(Int, Int)] | |
nonDiagIndices n = [(a,b) | a <- [0 .. n-1], b <- [0..n-1], a /= b] | |
gen :: [Bool] -> [Bool] | |
gen ss = ws | |
where |
This file contains hidden or 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 RecordWildCards #-} | |
module Main where | |
data Set = Set { first :: Int | |
, second :: Int | |
, third :: Int | |
} deriving (Eq, Show) | |
data Permutation = Permutation { mapping :: Set -> Set | |
, name :: String } |