My own corner of monopam
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

readmes: drop the trailing ;; from MDX toplevel phrases

MDX accepts toplevel phrases without the OCaml-toplevel ;;
terminator; the # prompt on the next line is enough. Strip the
noise across the 13 READMEs wired into MDX, and update the
monopam:readme skill's examples to match.

+54 -52
+5 -5
ocaml-atproto-handle/README.md
··· 39 39 40 40 ```ocaml 41 41 # let parse s = 42 - Atproto_handle.of_string s |> Result.map Atproto_handle.to_string;; 42 + Atproto_handle.of_string s |> Result.map Atproto_handle.to_string 43 43 val parse : string -> (string, Atproto_handle.error) result = <fun> 44 - # parse "Alice.BSky.Social";; 44 + # parse "Alice.BSky.Social" 45 45 - : (string, Atproto_handle.error) result = Ok "alice.bsky.social" 46 - # parse "alice..bsky.social";; 46 + # parse "alice..bsky.social" 47 47 - : (string, Atproto_handle.error) result = Error (`Msg "empty label") 48 - # parse "alice.local";; 48 + # parse "alice.local" 49 49 - : (string, Atproto_handle.error) result = 50 50 Error (`Msg "handle \"alice.local\" uses reserved TLD \"local\"") 51 51 ``` ··· 69 69 70 70 ```ocaml 71 71 # Atproto_handle_resolve.url_of_handle 72 - (Atproto_handle.of_string_exn "alice.bsky.social");; 72 + (Atproto_handle.of_string_exn "alice.bsky.social") 73 73 - : string = "https://alice.bsky.social/.well-known/atproto-did" 74 74 ``` 75 75
+9 -7
ocaml-claude-skills/plugins/monopam/skills/readme/SKILL.md
··· 142 142 143 143 ### Toplevel blocks — show output 144 144 145 - Use toplevel prompts (`# expr;;`) to interleave expressions with their 146 - expected output. Great for demonstrating a public API's return values: 145 + Use toplevel prompts (`# expr`) to interleave expressions with their 146 + expected output. Great for demonstrating a public API's return 147 + values. MDX does **not** require the trailing `;;` that a real OCaml 148 + toplevel expects — omit it: 147 149 148 150 ````markdown 149 151 ```ocaml 150 - # Foo.parse "Alice.Example.Com";; 152 + # Foo.parse "Alice.Example.Com" 151 153 - : (string, Foo.error) result = Ok "alice.example.com" 152 - # Foo.parse "bad..input";; 154 + # Foo.parse "bad..input" 153 155 - : (string, Foo.error) result = Error (`Msg "empty label") 154 156 ``` 155 157 ```` 156 158 157 - The output after each `;;` must match MDX's exact formatting. Run 159 + The output after each phrase must match MDX's exact formatting. Run 158 160 `dune runtest` once, inspect the `.corrected` file it produces, and 159 161 copy the authoritative output back into the README. 160 162 ··· 166 168 167 169 ````markdown 168 170 ```ocaml 169 - # let parse s = Foo.of_string s |> Result.map Foo.to_string;; 171 + # let parse s = Foo.of_string s |> Result.map Foo.to_string 170 172 val parse : string -> (string, Foo.error) result = <fun> 171 - # parse "alice.example.com";; 173 + # parse "alice.example.com" 172 174 - : (string, Foo.error) result = Ok "alice.example.com" 173 175 ``` 174 176 ````
+3 -3
ocaml-contact/README.md
··· 46 46 let tle = Result.get_ok (Sgp4.parse_tle_string tle_string) in 47 47 let la = Contact.ground_station ~lat:34.05 ~lon:(-118.25) ~alt:0.071 in 48 48 let passes = Contact.predict tle la ~duration_days:3.0 in 49 - List.length passes;; 49 + List.length passes 50 50 - : int = 15 51 51 ``` 52 52 ··· 64 64 | { max_elevation; duration; _ } :: _ -> 65 65 Fmt.str "first pass: %.1f deg peak, %.0fs long" 66 66 max_elevation duration 67 - | [] -> "no passes";; 67 + | [] -> "no passes" 68 68 - : string = "first pass: 61.6 deg peak, 630s long" 69 69 ``` 70 70 ··· 81 81 let epoch_unix = Sgp4.epoch_unix tle in 82 82 match Contact.elevation tle la epoch_unix with 83 83 | Some el -> Fmt.str "%.2f" el 84 - | None -> "N/A";; 84 + | None -> "N/A" 85 85 - : string = "-43.84" 86 86 ``` 87 87
+6 -6
ocaml-crdt/README.md
··· 42 42 ```ocaml 43 43 # let a = Crdt.G_counter.(empty |> increment ~node:"a" |> increment ~node:"a") 44 44 and b = Crdt.G_counter.(empty |> increment ~node:"b") in 45 - Crdt.G_counter.value (Crdt.G_counter.merge a b);; 45 + Crdt.G_counter.value (Crdt.G_counter.merge a b) 46 46 - : int = 3 47 47 ``` 48 48 ··· 53 53 |> increment ~node:"a" 54 54 |> increment ~node:"b" 55 55 |> decrement ~node:"a") in 56 - Crdt.PN_counter.value c;; 56 + Crdt.PN_counter.value c 57 57 - : int = 1 58 58 ``` 59 59 ··· 66 66 |> set ~timestamp:1L "first" 67 67 |> set ~timestamp:3L "third" 68 68 |> set ~timestamp:2L "second") in 69 - Crdt.LWW_register.get r;; 69 + Crdt.LWW_register.get r 70 70 - : string = "third" 71 71 ``` 72 72 ··· 76 76 # let a = Crdt.MV_register.(empty |> set ~node:"a" "alpha") 77 77 and b = Crdt.MV_register.(empty |> set ~node:"b" "beta") in 78 78 List.sort compare 79 - (Crdt.MV_register.get (Crdt.MV_register.merge a b));; 79 + (Crdt.MV_register.get (Crdt.MV_register.merge a b)) 80 80 - : string list = ["alpha"; "beta"] 81 81 ``` 82 82 ··· 86 86 87 87 ```ocaml 88 88 # let s = Crdt.G_set.(empty |> add 1 |> add 2 |> add 1) in 89 - List.sort compare (Crdt.G_set.elements s);; 89 + List.sort compare (Crdt.G_set.elements s) 90 90 - : int list = [1; 2] 91 91 ``` 92 92 ··· 98 98 |> add ~node:"a" "x" 99 99 |> add ~node:"a" "y" 100 100 |> remove String.equal "x") in 101 - Crdt.OR_set.elements String.equal s;; 101 + Crdt.OR_set.elements String.equal s 102 102 - : string list = ["y"] 103 103 ``` 104 104
+3 -3
ocaml-ewah/README.md
··· 39 39 40 40 ```ocaml 41 41 # let b = Ewah.of_indices [3; 7; 42; 1_000] in 42 - (Ewah.length b, Ewah.cardinal b, Ewah.mem b 7, Ewah.mem b 8);; 42 + (Ewah.length b, Ewah.cardinal b, Ewah.mem b 7, Ewah.mem b 8) 43 43 - : int * int * bool * bool = (1001, 4, true, false) 44 44 ``` 45 45 ··· 51 51 # let a = Ewah.of_indices [1; 2; 3; 10] 52 52 and b = Ewah.of_indices [2; 3; 4; 10] in 53 53 (Ewah.to_indices (Ewah.inter a b), 54 - Ewah.to_indices (Ewah.diff a b));; 54 + Ewah.to_indices (Ewah.diff a b)) 55 55 - : int list * int list = ([2; 3; 10], [1]) 56 56 ``` 57 57 ··· 64 64 # let bytes = Ewah.to_bytes (Ewah.of_indices [0; 63; 64; 128]) in 65 65 match Ewah.of_bytes bytes with 66 66 | Ok b -> Ewah.to_indices b 67 - | Error (`Msg m) -> failwith m;; 67 + | Error (`Msg m) -> failwith m 68 68 - : int list = [0; 63; 64; 128] 69 69 ``` 70 70
+4 -4
ocaml-flexacm/README.md
··· 38 38 ```ocaml 39 39 # let m = Flexacm.thirty_two_apsk_5_6 in 40 40 Fmt.str "%a %.2f bits/symbol" 41 - Flexacm.pp_modulation m.modulation m.spectral_efficiency;; 41 + Flexacm.pp_modulation m.modulation m.spectral_efficiency 42 42 - : string = "32-APSK 4.17 bits/symbol" 43 43 ``` 44 44 ··· 48 48 # let m = 49 49 Flexacm.acm_mode ~mode_id:42 50 50 ~modulation:Flexacm.Sixteen_APSK ~code_rate:Flexacm.Rate_3_4 in 51 - (m.mode_id, m.spectral_efficiency);; 51 + (m.mode_id, m.spectral_efficiency) 52 52 - : int * float = (42, 3.) 53 53 ``` 54 54 ··· 63 63 acm_mode_id = Flexacm.qpsk_1_2.mode_id; 64 64 frame_len = 2048 } in 65 65 let frame = Flexacm.frame ~plop (Bytes.of_string "coded bytes") in 66 - Fmt.str "%a" Flexacm.pp_frame frame;; 66 + Fmt.str "%a" Flexacm.pp_frame frame 67 67 - : string = "{ plop={ plop=PLOP-2; mode=2; frame_len=2048 }; data_len=11 }" 68 68 ``` 69 69 ··· 80 80 Flexacm.thirty_two_apsk_5_6 ] in 81 81 match Flexacm.mode_for_snr table 8.0 with 82 82 | Some m -> Fmt.str "%a" Flexacm.pp_modulation m.modulation 83 - | None -> "link budget too low";; 83 + | None -> "link budget too low" 84 84 - : string = "16-APSK" 85 85 ``` 86 86
+3 -3
ocaml-fsr/README.md
··· 41 41 Fsr.v ~alarm:false ~bad_sn:false ~bad_mac:false ~bad_sa:false 42 42 ~spi:0x0042 ~arsn_lsb:0x7b in 43 43 let word = Fsr.encode fsr in 44 - Result.map (fun r -> (r.Fsr.spi, r.Fsr.arsn_lsb)) (Fsr.decode word);; 44 + Result.map (fun r -> (r.Fsr.spi, r.Fsr.arsn_lsb)) (Fsr.decode word) 45 45 - : (int * int, [ `Invalid_version of int | `Not_fsr ]) result = Ok (66, 123) 46 46 ``` 47 47 ··· 52 52 # let fsr = 53 53 Fsr.initial 54 54 |> Fsr.update ~bad_mac:true ~spi:0x0042 ~arsn_lsb:0x01 in 55 - (Fsr.has_error fsr, fsr.alarm);; 55 + (Fsr.has_error fsr, fsr.alarm) 56 56 - : bool * bool = (true, true) 57 57 ``` 58 58 ··· 60 60 a CLCW, not an FSR: 61 61 62 62 ```ocaml 63 - # Fsr.decode 0l;; 63 + # Fsr.decode 0l 64 64 - : (Fsr.t, [ `Invalid_version of int | `Not_fsr ]) result = Error `Not_fsr 65 65 ``` 66 66
+2 -2
ocaml-ldpc/README.md
··· 39 39 ```ocaml 40 40 # let data = Bytes.make 128 '\x5a' in 41 41 let codeword = Ldpc.encode Ldpc.ccsds_rate_1_2 data in 42 - Bytes.length codeword;; 42 + Bytes.length codeword 43 43 - : int = 256 44 44 ``` 45 45 ··· 57 57 done; 58 58 match Ldpc.decode ~max_iter:50 Ldpc.ccsds_rate_1_2 codeword with 59 59 | Ok recovered -> Bytes.equal recovered data 60 - | Error _ -> false;; 60 + | Error _ -> false 61 61 - : bool = true 62 62 ``` 63 63
+4 -4
ocaml-merge3/README.md
··· 40 40 ```ocaml 41 41 # let a = [| "one"; "two"; "three" |] 42 42 and b = [| "one"; "TWO"; "three" |] in 43 - Merge3.diff ~eq:String.equal a b;; 43 + Merge3.diff ~eq:String.equal a b 44 44 - : string Merge3.edit list = 45 45 [Merge3.Keep "one"; Merge3.Delete "two"; Merge3.Insert "TWO"; 46 46 Merge3.Keep "three"] ··· 57 57 # let base = "a\nb\nc\n" 58 58 and ours = "a\nB1\nc\n" 59 59 and theirs = "a\nB2\nc\n" in 60 - print_string (Merge3.to_string (Merge3.merge ~base ~ours ~theirs ()));; 60 + print_string (Merge3.to_string (Merge3.merge ~base ~ours ~theirs ())) 61 61 a 62 62 <<<<<<< ours 63 63 B1 ··· 75 75 Merge3.merge ~base:"a\nb\nc\n" 76 76 ~ours:"a\nb\nc\n" 77 77 ~theirs:"a\nb\nC\n" () in 78 - Merge3.has_conflicts chunks;; 78 + Merge3.has_conflicts chunks 79 79 - : bool = false 80 80 ``` 81 81 ··· 87 87 ```ocaml 88 88 # let merge_int = Merge3.default ~eq:Int.equal in 89 89 let merge_pair = Merge3.pair merge_int (Merge3.option merge_int) in 90 - merge_pair ~old:(Some (1, None)) (1, Some 2) (1, Some 2);; 90 + merge_pair ~old:(Some (1, None)) (1, Some 2) (1, Some 2) 91 91 - : (int * int option) Merge3.result = Merge3.Ok (1, Some 2) 92 92 ``` 93 93
+3 -3
ocaml-mst/README.md
··· 80 80 let t = Mst.add store t ~key:"b/3" ~value:(Hash.digest "three") in 81 81 (Mst.mem store t ~key:"a/2", 82 82 Mst.mem store t ~key:"missing", 83 - List.of_seq (Mst.range store t ~lo:"a/" ~hi:"b/") |> List.map fst);; 83 + List.of_seq (Mst.range store t ~lo:"a/" ~hi:"b/") |> List.map fst) 84 84 - : bool * bool * string list = (true, false, ["a/1"; "a/2"]) 85 85 ``` 86 86 ··· 101 101 [ "a", "1"; "b", "2"; "c", "3" ] in 102 102 let t1 = Mst.remove store t0 ~key:"b" in 103 103 let t1 = Mst.add store t1 ~key:"d" ~value:(Hash.digest "4") in 104 - Mst.diff store ~old:t0 ~new_:t1 |> Seq.map summary |> List.of_seq;; 104 + Mst.diff store ~old:t0 ~new_:t1 |> Seq.map summary |> List.of_seq 105 105 - : string list = ["-b"; "+d"] 106 106 ``` 107 107 ··· 120 120 { Mst.hash = M.hash_ops; layering = Mst.sha256_2bit; codec } in 121 121 match Mst.of_hash config store root with 122 122 | Ok t' -> Mst.equal t t' 123 - | Error (`Msg _) -> false;; 123 + | Error (`Msg _) -> false 124 124 - : bool = true 125 125 ``` 126 126
+3 -3
ocaml-proximity1/README.md
··· 44 44 let wire = Proximity1.encode frame in 45 45 match Proximity1.decode wire with 46 46 | Ok f -> Proximity1.equal f frame 47 - | Error _ -> false;; 47 + | Error _ -> false 48 48 - : bool = true 49 49 ``` 50 50 ··· 57 57 frame_type = Proximity1.Ack; 58 58 sequence_count = 7; 59 59 data = "" } in 60 - String.length (Proximity1.encode frame) - Proximity1.header_size;; 60 + String.length (Proximity1.encode frame) - Proximity1.header_size 61 61 - : int = 0 62 62 ``` 63 63 ··· 66 66 "unrecognized traffic": 67 67 68 68 ```ocaml 69 - # Proximity1.decode "short";; 69 + # Proximity1.decode "short" 70 70 - : (Proximity1.t, [ `Invalid_frame_type of int | `Truncated ]) result = 71 71 Error `Truncated 72 72 ```
+3 -3
ocaml-reed-solomon/README.md
··· 43 43 ```ocaml 44 44 # let data = Bytes.make 223 '\x42' in 45 45 let codeword = Reed_solomon.encode_systematic Reed_solomon.ccsds data in 46 - Bytes.length codeword;; 46 + Bytes.length codeword 47 47 - : int = 255 48 48 ``` 49 49 ··· 60 60 done; 61 61 match Reed_solomon.decode Reed_solomon.ccsds codeword with 62 62 | Ok recovered -> String.sub (Bytes.to_string recovered) 0 19 63 - | Error e -> Fmt.str "decode failed: %a" Reed_solomon.pp_error e;; 63 + | Error e -> Fmt.str "decode failed: %a" Reed_solomon.pp_error e 64 64 - : string = "hello, reed-solomon" 65 65 ``` 66 66 ··· 73 73 for i = 0 to 16 do Bytes.set_uint8 codeword i 0xff done; 74 74 match Reed_solomon.decode Reed_solomon.ccsds codeword with 75 75 | Ok _ -> "unexpectedly recovered" 76 - | Error e -> Fmt.str "decode failed: %a" Reed_solomon.pp_error e;; 76 + | Error e -> Fmt.str "decode failed: %a" Reed_solomon.pp_error e 77 77 - : string = "decode failed: Chien search failed to find roots" 78 78 ``` 79 79
+2 -2
ocaml-viterbi/README.md
··· 40 40 let coded = Viterbi.encode Viterbi.ccsds data in 41 41 match Viterbi.decode Viterbi.ccsds coded with 42 42 | Ok out -> Bytes.to_string out 43 - | Error e -> failwith e;; 43 + | Error e -> failwith e 44 44 - : string = "hello" 45 45 ``` 46 46 ··· 55 55 Bytes.set_uint8 corrupted 3 (Bytes.get_uint8 corrupted 3 lxor 1); 56 56 match Viterbi.decode Viterbi.ccsds corrupted with 57 57 | Ok out -> Bytes.to_string out 58 - | Error e -> failwith e;; 58 + | Error e -> failwith e 59 59 - : string = "hello" 60 60 ``` 61 61
+4 -4
ocaml-websocket/README.md
··· 39 39 ```ocaml 40 40 # let frame = Websocket.text "hello" in 41 41 let bytes = Websocket.encode frame in 42 - String.length bytes;; 42 + String.length bytes 43 43 - : int = 11 44 44 ``` 45 45 ··· 53 53 Fmt.str "opcode=%a payload=%S fin=%b rest=%d" 54 54 Websocket.pp_opcode opcode payload fin (String.length rest) 55 55 | Error `Need_more -> "need more" 56 - | Error (`Invalid m) -> "invalid: " ^ m;; 56 + | Error (`Invalid m) -> "invalid: " ^ m 57 57 - : string = "opcode=text payload=\"hello\" fin=true rest=0" 58 58 ``` 59 59 ··· 63 63 ```ocaml 64 64 # let full = Websocket.encode ~mask:false (Websocket.binary "\x01\x02\x03") in 65 65 let partial = String.sub full 0 (String.length full - 1) in 66 - Websocket.decode partial;; 66 + Websocket.decode partial 67 67 - : (Websocket.t * string, [ `Invalid of string | `Need_more ]) result = 68 68 Error `Need_more 69 69 ``` ··· 73 73 ```ocaml 74 74 # let p = Websocket.ping "keepalive" 75 75 and c = Websocket.close ~code:1000 ~reason:"normal" () in 76 - (p.opcode, c.opcode);; 76 + (p.opcode, c.opcode) 77 77 - : Websocket.opcode * Websocket.opcode = (Websocket.Ping, Websocket.Close) 78 78 ``` 79 79