(* raw continuation *)
type ('a,'b) stack
perform : 'a eff -> 'a
resume : ('a,'b) stack -> ('c -> 'a) -> 'c -> 'b
delegate : 'a eff -> ('a,'b) stack -> 'b
This file contains 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 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 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 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 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 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 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 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
## 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 |
This file contains 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,_). |
NewerOlder