Skip to content

Instantly share code, notes, and snippets.

View kayceesrk's full-sized avatar

KC Sivaramakrishnan kayceesrk

View GitHub Profile
FROM ocaml/opam:raspbian-8_ocaml-4.02.3
RUN opam remote add main https://opam.ocaml.org
RUN opam pin add -y merlin https://github.com/the-lambda-church/merlin.git#reason-0.0.1
RUN opam pin add -y merlin_extend https://github.com/let-def/merlin-extend.git#reason-0.0.1
RUN opam pin add -y reason https://github.com/facebook/reason.git#0.0.6
(* Fun with behavioral types. Inspired by https://hal.archives-ouvertes.fr/hal-01216310 *)
type ('a,'b) test_result = True of 'a | False of 'b
module type Ref =
sig
type ('a, 'b) ref constraint 'b = [>]
(* 'b is the behavioural type variable *)
val ref : 'a -> ('a, 'b) ref
(* Fun with behavioral types. Inspired by https://hal.archives-ouvertes.fr/hal-01216310 *)
module type Ref =
sig
type ('a, 'b) ref constraint 'b = [>]
(* 'b is the behavioural type variable *)
val ref : 'a -> ('a, 'b) ref
val read : ('a, [`Read of 'b]) ref -> 'a * ('a, 'b) ref
(* Require `Read capability. 'b is the continuation's behavior. *)
(* Fun with behavioral types. Inspired by https://hal.archives-ouvertes.fr/hal-01216310 *)
exception LinearityViolation
module type Ref =
sig
type ('a, 'b) ref constraint 'b = [>]
(* 'b is the behavioural type variable *)
val ref : 'a -> ('a, 'b) ref

p2p key-value store over datakit

Data Model

Key -> Path
Value -> Json

The value is possibly JSON automatically generated for OCaml type definitions using ppx_deriving_yojson library. Merge function must be explicitly specified:

module Main where
import Debug.Trace
import Control.Exception.Base
import Control.Monad
import Control.Concurrent
import Control.Concurrent.STM
type MyChan a = (TVar (Maybe a), TVar Bool)
newMyChan :: IO (MyChan a)
#!/bin/sh
sort -n | awk '
BEGIN {
c = 0;
sum = 0;
}
$1 ~ /^[0-9]*(\.[0-9]*)?$/ {
a[c++] = $1;
sum += $1;
}
## Docker file for OCaml with GDB support
#
# Build
# -----
# $ mkdir monda-docker
# $ cp <this_file> monda-docker/
# $ docker build --force-rm=true -t monda .
# ..takes a while..
#
# Run
module type Handler = sig
type effect = ..
type 'a t
type cont
val return : 'a -> 'a t
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
val run : unit t -> unit
val handle : 'a t -> (effect -> cont -> unit t) -> unit t
val continue : cont -> unit t
/***********************************************************************/
/* */
/* OCaml */
/* */
/* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
/* */
/* Copyright 2009 Institut National de Recherche en Informatique et */
/* en Automatique. All rights reserved. This file is distributed */
/* under the terms of the GNU Library General Public License, with */
/* the special exception on linking described in file ../../LICENSE. */