Skip to content

Instantly share code, notes, and snippets.

sealed trait Task[A] {
import Task._
final def flatMap[B](f: A => Task[B]): Task[B] = Suspend(this, f)
final def map[B](f: A => B): Task[B] = this match {
case Suspend(inner, suspension) =>
Suspend(inner, suspension andThen { _ map f })
case Async(body) =>
@devdazed
devdazed / slack-pagerduty-oncall.py
Last active April 18, 2024 10:28
Updates a Slack User Group with People that are on call in PagerDuty
#!/usr/bin/env python
from __future__ import print_function
import json
import logging
from urllib2 import Request, urlopen, URLError, HTTPError
from base64 import b64decode
@bishboria
bishboria / springer-free-maths-books.md
Last active June 8, 2024 06:39
Springer made a bunch of books available for free, these were the direct links
@SeanTAllen
SeanTAllen / gist:7cbb72339806f3decee2
Last active October 7, 2015 22:53
The Tech "People" Bookclub
Here's the idea,
You work in tech. You're in the NYC area.
You care about "people" issues. You think the hardest problem in computing is "people".
You are interested in how we work. How to structure work. How to work together.
How to help your colleagues succeed.
And...
There's so much to learn:

Things that programmers don't know but should

(A book that I might eventually write!)

Gary Bernhardt

I imagine each of these chapters being about 2,000 words, making the whole book about the size of a small novel. For comparison, articles in large papers like the New York Times average about 1,200 words. Each topic gets whatever level of detail I can fit into that space. For simple topics, that's a lot of space: I can probably walk through a very basic, but working, implementation of the IP protocol.

@dbp
dbp / circle.yml
Last active June 29, 2017 09:53
Haskell project with Stack on CircleCI
dependencies:
cache_directories:
- "~/.stack"
pre:
- wget https://github.com/commercialhaskell/stack/releases/download/v0.1.2.0/stack-0.1.2.0-x86_64-linux.gz -O /tmp/stack.gz
- gunzip /tmp/stack.gz && chmod +x /tmp/stack
- sudo mv /tmp/stack /usr/bin/stack
override:
- stack setup
- stack build
/*
The MIT License (MIT)
Copyright (c) 2014
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
// In Haskell, a type that implements the Monad type class has the following functions:
//
// return :: a -> m a
// bind :: m a -> (a -> m b) -> m b
//
// The Monad type classes could have also been implemented as:
//
// return :: a -> m a
// fmap :: (a -> b) -> m a -> m b
// join :: m (m a) -> m a
@nraychaudhuri
nraychaudhuri / TypedAkkaActorRef.scala
Last active August 29, 2015 14:05
Typed Akka actor ref
//PLEASE NOTE: Typing actor refs are really hard problem(take a look at the discussions in Akka mailing list regarding this subject). This is no way a complete solution. This will only work if you know all the possible
//messages an actor can handle (that means no become/unbecome business).
package experiment
import akka.actor.{Props, ActorSystem, Actor, ActorRef}
case class TypedActorRef[A](actorRef: ActorRef) extends AnyVal {
def ![B](msg: B)(implicit ev: A <:< B, sender: ActorRef = Actor.noSender) = actorRef ! msg
}
@pchiusano
pchiusano / type-inhabitants.markdown
Last active January 7, 2023 17:23
Reasoning about type inhabitants in Haskell

This is material to go along with a 2014 Boston Haskell talk.

We are going to look at a series of type signatures in Haskell and explore how parametricity (or lack thereof) lets us constrain what a function is allowed to do.

Let's start with a decidedly non-generic function signature. What are the possible implementations of this function which typecheck?

wrangle :: Int -> Int