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
# recursively replace all occurrences of something. | |
find dir -type f -name '*.hs' -print0 | \\ | |
xargs -0 sed -i 's/Find/Replace/g' | |
# recursively remove all trailing whitespace | |
find dir -type f -print0 | \\ | |
xargs -0 sed -i 's/[ \t]*S//' | |
# recursively add newlines to the end of files that don't have them. | |
find dir -type f -print0 | xargs -0 sed -i -e '$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
-- | JSON parse helper. | |
-- | |
-- data Foo = Foo { fooIntBar :: Int, fooStringBar :: String } | |
-- deriving (Generic) | |
-- | |
-- -- This will make 'Foo''s fields get parsed as | |
-- -- 'int_bar', 'string_bar', etc. | |
-- instance FromJSON Foo where | |
-- parseJSON = parseJSONFielded | |
parseJSONFielded :: forall a. (Generic a, Typeable a, AE.GFromJSON AE.Z |
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
fibs10 :: [NUI] | |
fibs10 = take 10 fibs | |
fibs :: [NUI] | |
fibs = unPolynomial $ star (Polynomial [NUI 0, NUI 1, NUI 1]) | |
-- | \mathbb{N} \bigcup \infty | |
data NUI = NUI Word | Inf | |
deriving (Eq, Show) | |
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
byteArrayToByteString :: ByteArray -> ByteString | |
byteArrayToByteString (ByteArray b#) = | |
let contents# = byteArrayContents# b# | |
fp = ForeignPtr contents# (PlainPtr (byteArrayToMutableByteArray b#)) | |
len = lenAddr contents# | |
in PS fp 0 len | |
byteArrayToMutableByteArray :: ByteArray# -> MutableByteArray# RealWorld | |
byteArrayToMutableByteArray = unsafeCoerce# |
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
[nix-shell:~/Development/containers]$ ./dist/build/sequence-benchmarks/sequence-benchmarks | |
benchmarking splitAt/append/10 | |
time 691.1 μs (690.4 μs .. 692.4 μs) | |
1.000 R² (1.000 R² .. 1.000 R²) | |
mean 693.1 μs (691.5 μs .. 696.5 μs) | |
std dev 7.658 μs (2.571 μs .. 12.73 μs) | |
benchmarking splitAt/append/100 | |
time 4.301 ms (4.295 ms .. 4.308 ms) | |
1.000 R² (1.000 R² .. 1.000 R²) |
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
[chessai@chessai-kudu:~/Development/summoner/summoner-cli]$ cat default.nix | |
{ compiler ? "ghc863" }: | |
with rec { | |
pkgs = (import ./nix/nixpkgs.nix { | |
inherit compiler; | |
}); | |
drv = pkgs.haskellPackages.summoner-cli; | |
}; |
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
[1 of 1] Compiling ParseFooA ( foo.hs, foo.o ) | |
==================== Tidy Core ==================== | |
Result size of Tidy Core | |
= {terms: 816, types: 382, coercions: 40, joins: 0/9} | |
-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} | |
$trModule4 | |
$trModule4 = "main"# |
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
-- | ghc foo.hs -ddump-simpl -dsuppress-all -fforce-recomp -O2 | |
[1 of 1] Compiling ParseFoo ( foo.hs, foo.o ) | |
==================== Tidy Core ==================== | |
Result size of Tidy Core | |
= {terms: 260, types: 105, coercions: 10, joins: 0/3} | |
-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} | |
$trModule4 |
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
owner = "chessai" | |
fullName = "chessai" | |
email = "[email protected]" | |
license = "BSD3" | |
lib = true | |
exe = false | |
test = true | |
bench = false | |
github = true | |
private = false |
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 RankNTypes #-} | |
module Rank2CatMaybes (catMaybes) where | |
import Data.Coerce (coerce) | |
import Data.Functor.Identity (Identity(Identity)) | |
import qualified Rank2 | |
liftId :: (forall x. x -> Identity x) | |
liftId = coerce |