I hereby claim:
- I am jedahu on github.
- I am jedahu (https://keybase.io/jedahu) on keybase.
- I have a public key ASAEDZtMXX9XenWwUEArDrIcIWeR7Zpc2RIfw-UPq5ILjgo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
package gettyped | |
sealed abstract class Maybe[A] { | |
def fold[B](nothing: => B, just: A => B): B = this match { | |
case Nothing() => nothing | |
case Just(a) => just(a) | |
} | |
} | |
private final case class Nothing[A]() extends Maybe[A] {} |
The type class encoding in my previous post on the subject is a bit rubbish:
The Maybe
type I described could do with some type class instances, so
let’s try out a new encoding.
The previous post glossed over some features of C# that make functional programming difficult. Here they are explicitly addressed. Let’s call them warts. These warts make it difficult to reason about code and thus to write correct code.
Tony Hoare invented the null pointer and later apologised for doing so:
Welcome to the inaugural Functional Friday post. I intend to explore, as far as is possible in C#, what functional programming brings to the table: types, laws, and equational reasoning. Example code is in the C# project at the root of this repository.
First up: parametricity and type classes.
using System.Diagnostics.Contracts; | |
[ContractClass(typeof(ILanguageContract<>))] | |
public interface ILanguage<A> | |
{ | |
A Literal(string s); | |
string Escape(string s); | |
string Render(A a); | |
} |
using System.Collections.Generic; | |
using System.Diagnostics.Contracts; | |
using System.Linq; | |
[ContractClass(typeof(IValidatorContract<,>))] | |
public interface IValidator<E, in A> | |
{ | |
IEnumerable<E> Validate(A a); | |
} |
Create an executable (recapture
) that plays a signal through 24 audio ports and simultaneously records from another 24 ports. These ports come from three daisy chained Presonus FP10’s connected by firewire to a linux box. This hardware is accessed by the ffado jack drivers.