Skip to content

Instantly share code, notes, and snippets.

@Kakadu
Kakadu / a.ml
Created Sep 17, 2020
bad highlighting example
View a.ml
module TwoNilList = struct
open Helper
open OCanren
module L = struct
type ('a, 'self) t = Nil | Nil2 | Cons of 'a * 'self
[@@deriving gt ~options:{show; fmt; gmap}]
type 'a ground = ('a, 'a ground) t
[@@deriving gt ~options:{show;fmt; gmap}]
type 'a logic = ('a, 'a logic) t OCanren.logic
@Kakadu
Kakadu / cps.fs
Created Aug 24, 2020
cps vs non cps
View cps.fs
module Tour.Functions
type tree = Leaf | Node of tree * tree
let rec make depth =
if depth <= 0 then Leaf
else
let r = make (depth - 1) in
let l = if depth % 100000 = 0 then r else Leaf in
@Kakadu
Kakadu / log.txt
Last active Aug 18, 2020
dune, ppx and not -linkall flag
View log.txt
➜ gt-ppx git:(dune8-about-as) кь
➜ gt-ppx git:(dune8-about-as) rm -fr _build/default/.ppx
➜ gt-ppx git:(dune8-about-as) dune build regression/test822.exe --verbose
Workspace root: /media/oldhome/kakadu/prog/asp/gt-ppx
Running[0]: /usr/bin/nproc > /tmp/dune44ca62.output 2> /dev/null
Auto-detected concurrency: 4
disable binary cache
Running[1]: /home/kakadu/.opam/4.10.0+fp+flambda/bin/ocamlc.opt -config > /tmp/dune328a0c.output
Dune context:
{ name = "default"
@Kakadu
Kakadu / mkcamlp5.log
Created Aug 15, 2020
mkcamp5 doesn't work
View mkcamlp5.log
➜ gt-ppx git:(dune) ✗ mkcamlp5 -custom str.cmi str.cma -cclib -lstr -o camlp5str
don't know what to do with
Usage: ocamlc <options> <files>
Options are:
-a Build a library
-alert <list> Enable or disable alerts according to <list>:
+<alertname> enable alert <alertname>
-<alertname> disable alert <alertname>
++<alertname> treat <alertname> as fatal error
--<alertname> treat <alertname> as non-fatal
View gist:ea10d5df34257782dbd3c945f6fc1ef7
➜ dune-ocaml-ppx-bug git:(master) dune runtest
patdiff (internal) (exit 1)
(cd _build/default && /home/kakadu/.opam/4.09.0+fp+flambda/bin/patdiff -keep-whitespace -location-style omake -unrefined test_inline_test.ml test_inline_test.ml.corrected)
------ test_inline_test.ml
++++++ test_inline_test.ml.corrected
File "test_inline_test.ml", line 6, characters 0-1:
|
|let rec fact n = if n = 1 then 1 else n * fact (n - 1)
|
|let%expect_test _ =
@Kakadu
Kakadu / print.ml
Created May 10, 2020
playground for formatted printinf
View print.ml
#use "topfind";;
#rectypes;;
#require "GT";;
#require "GT.ppx";;
type lambda =
| Lambda of string * lambda
| Var of string
| Apply of lambda * lambda
[@@deriving gt]
View branches.txt
This file has been truncated, but you can view the full file.
➜ pat-match git:(master) ✗ make unn
dune exec unn/main_unnested.exe
test1 eval_m, 1 answer {
0ms
q=("pair" [aab; bbb], ["pair"]);
}
test1 eval_m, 1 answer {
0ms
q=(aab, ["aab"]);
View aaa.ml
let rec list_mem x xs (q178 as ans) =
let open Std in
conde
[ ((xs === (nil ())) &&& (q178 === (!! false)))
; fresh (h tl q181)
(xs === (h % tl))
(conde
[ (x === h) &&& (q178 === (!! true))
; (x =/= h) &&& (list_mem x tl q178)
])
@Kakadu
Kakadu / merlin.log
Created Apr 8, 2020
merlin 4.09 log
View merlin.log
# 8.46 lsp - debug (local)
recv: {
"id": "{3591cc33-d1d0-44f9-8fce-ffb493f36b1c}",
"jsonrpc": "2.0",
"method": "textDocument/documentHighlight",
"params": {
"position": { "character": 0, "line": 3 },
"textDocument": {
"uri": "file:///home/kakadu/prog/ocaml/lablqml/ppx/testdemo2.ml"
}
@Kakadu
Kakadu / reader_demo.ml
Created Feb 17, 2020
OCaml reader monad demo ( >= 4.09)
View reader_demo.ml
module Reader = struct
type ('r, 'a) t = { reader : 'r -> 'a }
let run_reader { reader } = reader
let reader f = { reader = f }
let return x = { reader = (fun _ -> x) }
let (>>=) x f = reader @@ fun r -> run_reader (f @@ run_reader x r) r
let ask = reader (fun x -> x)
let asks = reader
You can’t perform that action at this time.