This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
signature MONOID = | |
sig | |
type t | |
val append : t * t -> t | |
val zero : t | |
end | |
structure Additive = | |
struct | |
type t = int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ContextBoundsSyntax { | |
trait Monoid[A] { | |
def zero:A | |
def append (a:A, b:A) : A | |
} | |
implicit object AdditiveInt extends Monoid[Int] { | |
def zero = 0 | |
def append (a:Int, b:Int) = a + b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE NoMonomorphismRestriction #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
module DiagramsTidal where | |
import Sound.Tidal.Pattern hiding (square) | |
import Sound.Tidal.Time | |
import Sound.Tidal.Utils |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs> {}; { | |
pyEnv = stdenv.mkDerivation { | |
name = "py"; | |
buildInputs = [ | |
stdenv | |
python27 | |
blas | |
gcc | |
ffmpeg | |
] ++ (with python27Packages; [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE RecordWildCards #-} | |
data Person = Person {name :: String, address :: String} | |
me = Person {name = "Sean", address = "315 Seigel St"} | |
foo :: String | |
foo = | |
let Person{..} = me | |
in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- How do we make a tuple that's functorial over the first parameter? | |
-- We can't! | |
data Tup a b = Tup a b | |
instance Functor (Tup a) where | |
fmap f (Tup x y) = Tup x (f y) | |
instance Functor (Tup a) where | |
fmap f (Tup x y) = Tup x (f y) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let foo : int = | |
2 + 2 | |
let bar : float = | |
2.0 +. 2.0 | |
let baz : string = | |
string_of_int foo ^ string_of_float bar | |
// demonstration of ocaml's lack of ad-hoc polymorphism |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s.options.numBuffers = 1024 * 16; | |
s.waitForBoot{ | |
Routine{ | |
include("SuperDirt"); | |
2.wait; | |
SuperDirt.start; | |
}.play | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GADTSyntax #-} | |
-- | Derivation of fix without general recursion | |
-- | Transliteration of PFPL 2nd Ed, pp. 180 | |
module AnnotatedFix where | |
newtype Self t where | |
Fold :: (Self t -> t) -> Self t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newtype Self t = Fold { unfold :: Self t -> t} | |
fix :: (a -> a) -> a | |
fix f = unroll . Fold $ f . unroll | |
unroll :: Self t -> t | |
unroll e = unfold e e |