Skip to content

Instantly share code, notes, and snippets.

View owickstrom's full-sized avatar

Oskar Wickström owickstrom

View GitHub Profile
@owickstrom
owickstrom / Eq.purs
Last active August 29, 2015 14:19
Purescript Eq instance
module Main where
import Debug.Trace
data T = A | B Number
instance eqT :: Eq T where
A == A = true
(B v1) == (B v2) = v1 == v2
_ == _ = false
@owickstrom
owickstrom / Rackla.hs
Created May 12, 2015 11:09
Rackla Types (in my mind, at least)
module Main where
import Control.Applicative
-- value with type a is only for demo purposes, it would be supplied
-- asyncronously in Rackla (or with messages, I don't know how it works
-- exactly).
data PID a = PID a deriving (Show)
instance Functor PID where
@owickstrom
owickstrom / InstanceEffTrouble.purs
Last active August 29, 2015 14:21
Instance Effects Trouble
module Test.Spec where
import Debug.Trace
import Control.Monad
import Control.Monad.Error.Class
import Control.Monad.Trans
import Control.Monad.Eff
import Control.Monad.Eff.Exception
import Control.Monad.Eff.Class
import Control.Monad.Aff
{
"graph": {
"label": "Some Title",
"metadata": {
"id": "uc1"
},
"nodes": [
{
"id": "user",
"label": "User",
(ns scratch.core
(:require [clojure.core.typed :as t]))
(t/defalias DropboxEntry
(t/Rec [x]
(t/U '{:type (Value :file)
:path String
:mime-type String}
'{:type (Value :directory)
:path String
@owickstrom
owickstrom / type-system.rkt
Created October 12, 2015 06:14
Minimalistic type system hack in Racket.
#lang racket
(require "minikanren/mk.rkt")
(struct e/var (name) #:transparent)
(struct e/app (fn param) #:transparent)
(struct e/lam (arg body) #:transparent)
(define (t/fn domain range)
(list ':fn domain range))
@owickstrom
owickstrom / README.md
Last active October 27, 2015 08:46
Kashmir Programming Language - Draft
@owickstrom
owickstrom / based-on-existing-syntax.lisp
Last active January 22, 2016 08:52
Alternate syntax
(pkg main)
(import fmt)
;; if expressions
(: fib (int -> int))
(def (fib n)
(if (== n 1)
0
(if (== n 2)
@owickstrom
owickstrom / protocols.go
Last active April 11, 2016 12:06
Protocols sketches for Oden
//----------//
// SEMIRING //
//----------//
// Types that support addition and multiplication.
protocol Semiring(a) {
add : a -> a -> a
zero : a
mul : a -> a -> a
one : a
@owickstrom
owickstrom / Name.idr
Created October 13, 2016 05:52
Idris String with validation?
-- A data type wrapping a non-empty string
data Name : Type where
MkName : (s : String) -> (not (s == "") = True) -> Name
-- Some function that expects a valid Name
test : Name -> String
test (MkName s _) = s
-- Usage of that function. Do I need Refl here? Any better way of doing this?
foo : String