Skip to content

Instantly share code, notes, and snippets.

View seanparsons's full-sized avatar
💭
Setting A Status Message

Sean Parsons seanparsons

💭
Setting A Status Message
View GitHub Profile
@seanparsons
seanparsons / scratch.u
Created February 13, 2024 10:31
Cypher System Tasks Experiment
normalPage : Html -> Text
normalPage page =
use Text ++
"<!doctype html>" ++ html.toText page
name : Text -> Attribute
name = Attribute "name"
type TaskAttempt
= { difficulty : Nat, skills : Nat, assets : Nat, effort : Nat }
@seanparsons
seanparsons / gist:da84d5a3b7b3cdd10daa1761358398d1
Created June 12, 2022 09:53
nix-store fixed output derivation issue.
root@tower /e/nixos (master)# nix-store --debug --verbose --add-fixed sha256 rns_321_linux_x86_64.tar.gz
acquiring write lock on '/nix/var/nix/temproots/276929'
locking path '/nix/store/rkh6ijmm6qr7n8alpkhmzdj6ggrc7rdi-rns_321_linux_x86_64.tar.gz'
lock acquired on '/nix/store/rkh6ijmm6qr7n8alpkhmzdj6ggrc7rdi-rns_321_linux_x86_64.tar.gz.lock'
lock released on '/nix/store/rkh6ijmm6qr7n8alpkhmzdj6ggrc7rdi-rns_321_linux_x86_64.tar.gz.lock'
error: opening file '/nix/store/rkh6ijmm6qr7n8alpkhmzdj6ggrc7rdi-rns_321_linux_x86_64.tar.gz': No such file or directory
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.
@seanparsons
seanparsons / default.nix
Last active September 1, 2019 12:05
Problem with haskell.nix
{}:
let
config = {
allowUnfree = true;
};
bootstrap = import <nixpkgs> { };
nixpkgs = builtins.fromJSON (builtins.readFile ./nixpkgs.json);
nixpkgssrc = bootstrap.fetchFromGitHub {
owner = "NixOS";
@seanparsons
seanparsons / CaliperBenchmark.scala
Last active April 28, 2019 16:05
List.foldRight performance evaluation (run against Scala 2.10.0 with OpenJDK 1.7.0).
case class ListFoldRightBenchmark() extends SimpleScalaBenchmark {
import scala.collection.mutable.ArrayStack
@Param(Array("0", "1", "2", "3", "5", "10", "100", "500", "1000", "2000"))
val length: Int = 0
var list: List[Int] = _
override def setUp() {
// set up all your benchmark data here
@seanparsons
seanparsons / gist:3736483
Created September 17, 2012 09:46
Kleisli composition is to flatMap as function composition is to map.
scala> import scalaz._
import scalaz._
scala> import Scalaz._
import Scalaz._
scala> val a = (value: Int) => value * 2
a: Int => Int = <function1>
scala> val b = (value: Int) => value + 1

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 March 26, 2017 23:38
Back calculate pi from randomly generated numbers.
#!/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 / gist:964759
Created May 10, 2011 16:02
Akka ASCII art!
05/10 17:01:35 INFO [main] a.s.AkkaLoader - ==================================================
05/10 17:01:35 INFO [main] a.s.AkkaLoader - t
05/10 17:01:35 INFO [main] a.s.AkkaLoader - t t t
05/10 17:01:35 INFO [main] a.s.AkkaLoader - t t tt t
05/10 17:01:35 INFO [main] a.s.AkkaLoader - tt t t tt t
05/10 17:01:35 INFO [main] a.s.AkkaLoader - t ttttttt t ttt t
05/10 17:01:35 INFO [main] a.s.AkkaLoader - t tt ttt t ttt t
05/10 17:01:35 INFO [main] a.s.AkkaLoader - t t ttt t ttt t t
05/10 17:01:35 INFO [main] a.s.AkkaLoader - tt t ttt ttt ttt t
05/10 17:01:35 INFO [main] a.s.AkkaLoader - t t ttt ttt t tt t
@seanparsons
seanparsons / Error output
Created February 8, 2017 00:34
Could not match type
Could not match type
{ "third" :: Map t0 t1
| t2
}
with type
Model