Skip to content

Instantly share code, notes, and snippets.

View kayceesrk's full-sized avatar

KC Sivaramakrishnan kayceesrk

View GitHub Profile
(* deep_state.ml *)
open Effect
open Effect.Shallow
module type State = sig
type a
type _ Effect.t += Get : a Effect.t
type _ Effect.t += Set : a -> unit Effect.t
end
(* 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
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 =
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
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
# 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
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
?- 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
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

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).