Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Setting A Status Message

Sean Parsons seanparsons

💭
Setting A Status Message
View GitHub Profile
@seanparsons
seanparsons / default.nix
Last active Sep 1, 2019
Problem with haskell.nix
View default.nix
{}:
let
config = {
allowUnfree = true;
};
bootstrap = import <nixpkgs> { };
nixpkgs = builtins.fromJSON (builtins.readFile ./nixpkgs.json);
nixpkgssrc = bootstrap.fetchFromGitHub {
owner = "NixOS";
View gist:e80f2c65a3cbc8c36c21632a0eaeed88
It suffers from similar problems to Scala, where it tries to blend OO concepts in with FP concepts.
Variance is where this flares up terribly because it doesn't provide any explicit support for covariance or contravariance.
You end up with invariance and subtyping in a bunch of places which is not a nice combination.
Protocols like Equatable and Hashable are implemented with compiler magic for arrays and tuples.
Which means that you run into trouble with generic functions that say accept two instances of the same type which is Equatable if you pass an array of ints.
You can't say "for a List if the elements are Equatable the List is equatable" IIRC.
This one annoys me no end as we've had to fudge our way around it several times on the same project.
For some reason that eludes me, Optional<T> is given all sorts of special case syntax ("if let" and "guard let") which is like a crap version of "for yield" from Scala or do notation in Haskell that only works on that.
View keybase.md

Keybase proof

I hereby claim:

  • I am seanparsons on github.
  • I am seanparsons (https://keybase.io/seanparsons) on keybase.
  • I have a public key whose fingerprint is B38A 94B9 204E 4D58 8085 71EE 0577 F744 BE6D 8619

To claim this, I am signing this object:

@seanparsons
seanparsons / pifromrandomnumbers.hs
Last active Mar 26, 2017
Back calculate pi from randomly generated numbers.
View pifromrandomnumbers.hs
#!/usr/bin/env stack
-- stack --resolver lts-8.5 --nix runghc --package random
-- Requires the Haskell build tool Stack to be installed: https://docs.haskellstack.org/en/stable/README/
-- Create this file and make it executable using "chmod u+x pifromrandomnumbers.hs"
-- and run it with "./pifromrandomnumbers.hs" from a terminal.
{-# LANGUAGE StrictData #-}
{-# LANGUAGE Strict #-}
import System.Random
@seanparsons
seanparsons / Error output
Created Feb 8, 2017
Could not match type
View Error output
Could not match type
{ "third" :: Map t0 t1
| t2
}
with type
Model
@seanparsons
seanparsons / servant-cookie.hs
Last active Oct 29, 2016
Servant, powered by a free monad with cookies handled in a cross cutting way.
View servant-cookie.hs
View shell.nix
let
pkgs = import <nixpkgs> {};
name = "test";
in pkgs.myEnvFun {
buildInputs = [
pkgs.haskell.packages.ghcjs.ghcWithPackages(p: with p; [ ghcjs-base ghcjs-dom lens text ])
pkgs.nodejs
];
inherit name;
}
View .zshrc
unstable-shell () { nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz -j 8 $* }
ghci-with-deps () { unstable-shell -p "haskell.packages.ghc7103.ghcWithPackages (pkgs: with pkgs; [ghc $*])" --command ghci }
View trailcommas.scala
scala> "[,]".parse
res0: Either[String,argonaut.Json] = Left(Unexpected content found: ,])
scala> "{,}".parse
res1: Either[String,argonaut.Json] = Left(Expected string bounds but found: ,})
View gist:377ef410c6e83c216339
# ldd -v /home/sean/.stack/programs/x86_64-linux/ghc-7.10.2/lib/ghc-7.10.2/bin/ghc
linux-vdso.so.1 => (0x00007ffc6ebe6000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f13fcb50000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f13fc948000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f13fc744000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f13fc540000)
libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f13fc2c0000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f13fbfb7000)
libHShaskeline-0.7.2.1-1dVCRhdIH7hAQWJrKwByYv-ghc7.10.2.so => /home/sean/.stack/programs/x86_64-linux/ghc-7.10.2/lib/ghc-7.10.2/bin/../haske_1dVCRhdIH7hAQWJrKwByYv/libHShaskeline-0.7.2.1-1dVCRhdIH7hAQWJrKwByYv-ghc7.10.2.so (0x00007f13fbc33000)
libHSterminfo-0.4.0.1-KvtqTNXWuWjKicEYaZ7qsx-ghc7.10.2.so => /home/sean/.stack/programs/x86_64-linux/ghc-7.10.2/lib/ghc-7.10.2/bin/../termi_KvtqTNXWuWjKicEYaZ7qsx/libHSterminfo-0.4.0.1-KvtqTNXWuWjKicEYaZ7qsx-