Skip to content

Instantly share code, notes, and snippets.

View ulve's full-sized avatar

Olov Johansson ulve

  • Future Ordering
  • Umeå
View GitHub Profile
@ulve
ulve / reddit example.json
Created June 6, 2016 12:53
example of reddit comments
[
{
"kind": "Listing",
"data": {
"modhash": "",
"children": [
{
"kind": "t3",
"data": {
"domain": "engadget.com",
@ulve
ulve / reddit example.json
Created June 6, 2016 12:53
example of reddit comments
[
{
"kind": "Listing",
"data": {
"modhash": "",
"children": [
{
"kind": "t3",
"data": {
"domain": "engadget.com",

Keybase proof

I hereby claim:

  • I am ulve on github.
  • I am ulve (https://keybase.io/ulve) on keybase.
  • I have a public key whose fingerprint is 2DDB C99B 1110 AAB0 5FE7 23DD 9B9E 5784 633B 1F0A

To claim this, I am signing this object:

// @flow
import * as React from "react";
import * as Recompose from "recompose";
declare type HelloProps = {
compiler: string,
framework: string
};
const reducer = (state: ControllerState, action: Action): ControllerState => {
// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.
open FSharp.Data
open Microsoft.FSharp.Data.TypeProviders
open HttpFs.Client
open HttpFs
open Hopac
open Argu
open System
open System.Collections.Generic
@ulve
ulve / chart.html
Created October 4, 2017 15:35
D3 server graph
<!DOCTYPE html>
<html>
<head>
<title>Miljöinfo</title>
<meta charset="utf-8" />
</head>
<style>
.node {
fill: #f15;
@ulve
ulve / future.ts
Last active October 8, 2017 19:03
Future
// simple
const future = f => ({
fork: g => f(g),
map: g => future(k => f(l => k(g(l)))),
flatMap: g => future(k => f(l => g(l).apply(k)))
})
const getHttp = callback => {
const id = Math.floor(Math.random() * 5000 + 1000)
setTimeout(() => callback(`hej ${id}`), id)
@ulve
ulve / monadwriter.ts
Last active October 18, 2017 11:37
MonadWriter
class MonadWriter<T, V> {
private v:T;
private log:V[];
constructor(v:T, log:V[] | V) {
this.v = v;
if(log instanceof Array)
this.log = log;
else
this.log = [log];
@ulve
ulve / monadreader.ts
Last active October 23, 2017 06:37
MonadReader
class Reader<E, A> {
private constructor(protected k) {}
Run = (e: E): A => this.k(e);
Bind = <B>(f: (a: A) => Reader<E, B>): Reader<E, B> =>
new Reader(e => f(this.k(e)).Run(e));
Map = <B>(f: (a: A) => B): Reader<E, B> => new Reader(e => f(this.k(e)));
static Ask = <E, A>(): Reader<E, A> => new Reader(x => x);
static Asks = <E, A>(f: (a: E) => A): Reader<E, A> => new Reader(f);
static Unit = <E, A>(f: A): Reader<E, A> => new Reader(() => f);
}
@ulve
ulve / StateMonad.ts
Created October 23, 2017 10:40
StateMonad in TypeScript
class State {
private constructor(protected state) {}
Map = f =>
new State(s => {
var prev = this.state(s);
return { value: f(prev.value), state: prev.state };
});
Join = () =>