This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* 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 : sig | |
type t | |
val mk : float code -> t | |
val (+.) : t -> t -> t | |
val ( *. ) : t -> t -> t | |
val grad : (t -> t) -> float code -> float code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
?- 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,_). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 . && \ |
NewerOlder