Skip to content

Instantly share code, notes, and snippets.

var people = {
"heights": [2, 6, 10, 14, 18, 22, 26, 30],
"probabilities": [1, 2, 3, 4, 4, 3, 2, 1]
};
// generate a state of the form [john's height, bill's height]
var statePrior = function() {
return [categorical(people.probabilities, people.heights),categorical(people.probabilities, people.heights)];
};
@dylnb
dylnb / Paychecks.hs
Last active February 18, 2019 00:31
testing dependent currying
{-# LANGUAGE GADTs, FlexibleInstances #-}
module Paychecks where
type E = String
data Z
data S n
data Arity k where
@dylnb
dylnb / RoseTree.idr
Last active December 9, 2018 00:55
Dependent RoseTree
import Data.Vect
op : Nat -> Type -> Type
op Z a = a
op (S n) a = a -> op n a
mutual
data RoseTree : a -> Type where
Rose : (n : Nat ** OpTree n a) -> RoseTree a
{-# LANGUAGE TypeFamilies, FlexibleInstances, FlexibleContexts #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
module RecVP where
type Ent = Int
-- Dummy zero-ary type for individuals
data Stack a = Stack [a]
-- "Stack" is a dummy monadic constructor that wraps around any list of things
module FocusMonad where
data Focused e a =
Normal a
| FMarked e (Focused e (e -> a))
run :: Focused e a -> a
run (Normal a) = a
run (FMarked e f) = run f e
@dylnb
dylnb / App.hs
Last active February 18, 2017 16:20
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
module App where
class Apply f g ret | f g -> ret where
app :: f -> g -> ret
instance Applicative f => Apply (f (a -> b)) (f a) (f b) where
fs `app` xs = fs <*> xs
module NonDep where
import Control.Monad.Random
import System.IO.Unsafe
import Data.List (nub)
type Env = Int
data NonDep a = ND {unND :: Rand StdGen (Env -> a)}
instance Monad NonDep where
@dylnb
dylnb / ihaskell-test.ipynb
Last active August 29, 2015 14:26
ihaskell-test
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dylnb
dylnb / index.html
Last active August 29, 2015 13:58
Lambda Calculator: Exercise File Format
<html>
<head>
<title>Lambda Calculator - Exercise File Format</title>
<meta charset="UTF-8" />
<style>
pre {
border: 1px solid #CCCCCC;
background-color: #EEEEEE;
padding: .5em;
}
@dylnb
dylnb / index.html
Last active August 29, 2015 13:57
Lambda Calculator: Entering Special Symbols
<html>
<head>
<title>Lambda Calculator - Entering Special Symbols</title>
<meta charset="UTF-8" />
<style>
pre {
border: 1px solid #CCCCCC;
background-color: #EEEEEE;
padding: .5em;
}