Skip to content

Instantly share code, notes, and snippets.

@david-bakin
david-bakin / Result.java
Created November 11, 2015 05:03
Java Result class - union (sum) type of a success type and a failure type, with a "pattern matching" functional interface
package com.bakins_bits.types;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import com.google.common.base.Preconditions;
static class AsyncResultExtensions
{
//added to chain awaitable methods
public static async Task<Result<TResult>> OnSuccessAsync<T, TResult>(this Result<T> result, Func<T, Task<Result<TResult>>> func)
{
var res = result;
if (res.Failed)
return Result<TResult>.Fail(res.Error);
return await func(res.Value);
@theburningmonk
theburningmonk / abstract.txt
Last active December 24, 2015 16:01
Hack your commit history for fun and profit with F#
We programmers spend so much of our time coding everyday, and there's a wealth of information about
HOW we work hidden in our commit histories.
In this talk I'll share some of the ideas we experimented with to analyze our commit history in order
to gain insight into the way we work, and how the quality of our codebase has evolved over time.
Along the way, there were some rather interesting findings!
All the code examples will be in F#, but you can easily apply the same techniques in any other language.