Skip to content

Instantly share code, notes, and snippets.

Avatar

KC Sivaramakrishnan kayceesrk

View GitHub Profile
View binarytrees5.ml
(* The Computer Language Benchmarks Game
* https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
*
* Contributed by Troestler Christophe
* Modified by Fabrice Le Fessant
* *reset*
*)
type 'a tree = Empty | Node of 'a tree * 'a * 'a tree
View interntest.ml
type tree = Leaf of int | Node of tree * tree
let gensym = ref 0
let rec build_tree n =
if n <= 0
then (incr gensym; Leaf !gensym)
else Node(build_tree (n-1), build_tree (n-1))
let test n repet =
View state.ml
open Printf
open EffectHandlers
open EffectHandlers.Deep
module type STATE = sig
type t
val put : t -> unit
val get : unit -> t
val run : (unit -> 'a) -> init:t -> t * 'a
end
View clone_unsafe.ml
effect E : unit
let foo () =
let r = Atomic.make 0 in
perform E;
Atomic.set r (Atomic.get r + 1);
Atomic.get r
let bar () =
let r = ref 0 in
View find_slot.py
# Prints the slots available in Chennai for 18+ vaccination for the next 2
# weeks.
#
# Chennai's district id is 571.
# See https://apisetu.gov.in/public/marketplace/api/cowin#/Metadata%20APIs
import datetime
import requests
import json
View eff_gen.ml
let n = try int_of_string (Sys.argv.(1)) with _ -> 25
module MkGen (S :sig
type 'a t
val iter : ('a -> unit) -> 'a t -> unit
end) : sig
val gen : 'a S.t -> (unit -> 'a option)
end = struct
let gen : type a. a S.t -> (unit -> a option) = fun l ->
let module M = struct effect Yield : a -> unit end in
@kayceesrk
kayceesrk / stlc.prolog
Last active November 22, 2019 14:05
Type inference and program synthesis from simply typed lambda calculus type checking rules
View stlc.prolog
?- set_prolog_flag(occurs_check,true).
lookup([(X,A)|_],X,A).
lookup([(Y,_)|T],X,A) :- \+ X = Y, lookup(T,X,A).
/* Rules from the STLC lecture */
pred(D,DD) :- D >= 0, DD is D - 1.
type(_,u,unit,D) :- pred(D,_).
@kayceesrk
kayceesrk / Dockerfile
Created February 26, 2019 05:28
Dockerfile for installing irmin-unix
View Dockerfile
From ocaml/opam2
RUN sudo apt update
RUN sudo apt install -y m4 perl libgmp-dev pkg-config
RUN opam remote add upstream https://opam.ocaml.org && \
opam update && opam upgrade
RUN git clone https://github.com/mirage/irmin
WORKDIR irmin
RUN opam pin add -k git -n irmin . && \
opam pin add -k git -n irmin-unix . && \
opam pin add -k git -n irmin-fs . && \
@kayceesrk
kayceesrk / pldi18_aec_ldrf.md
Created July 2, 2018 12:31
PLDI 18 AEC LDRF
View pldi18_aec_ldrf.md

Artefact Evalution for "Bounding Data Races in Space and Time"

This document contains instructions for the artefact evaluation. The draft paper is available at kcsrk.info/papers/pldi18-memory.pdf.

Access to benchmarking machines

The main evaluation in the paper is the overhead of compiling our proposed memory model to relaxed architectures such as ARM and POWER (Fig 7 on page 10).

View reverse_mode_ad.ml
(* Reverse-mode algorithmic differentiation using effect handlers.
Adapted from https://twitter.com/tiarkrompf/status/963314799521222656.
See https://openreview.net/forum?id=SJxJtYkPG for more information. *)
module F = struct
type t = { v : float; mutable d : float }
let mk v = {v; d = 0.0}
effect Plus : t * t -> t