Skip to content

Instantly share code, notes, and snippets.

@mausch
mausch / gist:6774627
Created October 1, 2013 06:37
Applicative validation is simple.
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
// As opposed to magic validation libraries that rely on reflection and attributes,
// applicative validation is pure, total, composable, type-safe, works with immutable types, and it's easy to implement.
public abstract class Result<T> {
private Result() { }
{-# LANGUAGE OverloadedStrings #-}
import qualified Network.HTTP.Conduit as H
import Control.Exception
import Web.Scotty
import System.Environment
import System.IO
import System.Directory
import Control.Monad
import Control.Monad.IO.Class
import qualified Data.ByteString.Lazy.Char8 as BS
@liammclennan
liammclennan / 1.3.ss
Created May 5, 2013 04:36
Sicp 1.1 exercises
(define (doit a b c)
(define descending (sort (list a b c) >))
(+ (square (car descending)) (square (car (cdr descending))))
)
@xerxesb
xerxesb / gist:4654224
Last active December 11, 2015 20:18
First run at a solution to the Call Recording/Ordering kata
using System;
using System.Collections.Generic;
using System.Diagnostics;
using NUnit.Framework;
using Shouldly;
using System.Linq;
namespace MethodInfos
{
public class Formatter
@tonymorris
tonymorris / TypeClass.hs
Last active September 15, 2020 13:17
Type-class hierarchy
Moved to https://github.com/tonymorris/type-class
@liammclennan
liammclennan / blog_currying.md
Created September 6, 2012 10:48
CoffeeScript Currying

This is a function that does some currying:

add = (a,b) ->
  if not b?
    return (c) ->
      c + a
  a + b
@tonymorris
tonymorris / Lens.cs
Created August 5, 2012 05:43
Lens library for C# (demonstration)
using System;
using System.Collections;
using System.Collections.Generic;
/*
A basic lens library for the purpose of demonstration.
Implements a lens as the costate comonad coalgebra.
This library is not complete.
A more complete lens library would take from
@seanparsons
seanparsons / SKI_Applicative.scala
Created August 2, 2012 09:06 — forked from tonymorris/SKI_Applicative.scala
Applicative Functor / SKI combinator calculus
object SKI_Applicative {
/*
First, let's talk about the SK combinator calculus and how it contributes to solving your problem.
The SK combinator calculus is made of two functions (aka combinators): S and K. It is sometimes called the SKI combinator calculus,
however, the I combinator can be derived from S and K. The key observation of SK is that it is a turing-complete system and therefore,
anything that can be expressed as SK is also turing-complete. Here is a demonstration that Scala's type system is turing-complete
(and therefore, undecidable) for example[1].
The K combinator is the most trivial of the two. It is sometimes called "const" (as in Haskell). There is also some discussion about
@tonymorris
tonymorris / gist:3088073
Created July 11, 2012 04:42
Semigroup/Monoid/Semigroupoid/Category/Endo
class Semigroupoid cat where
(<.>) ::
cat a b
-> cat b c
-> cat a c
class Semigroupoid cat => Category cat where
identity ::
cat a a
@dtchepak
dtchepak / gist:3049721
Created July 4, 2012 21:54
What is OO?

I've been having a look around at various definitions of OO. Here's some of the ideas google turned up: