Add 'brolib-sml/' from commit 'fd96032949434207dda3b288f48d7fe579f59e4e'

git-subtree-dir: brolib-sml
git-subtree-mainline: 64471ecf7f
git-subtree-split: fd96032949
This commit is contained in:
2026-04-24 00:26:04 +01:00
48 changed files with 468057 additions and 0 deletions

47
brolib-sml/bench/Makefile Normal file
View File

@@ -0,0 +1,47 @@
bench: gap_buffer_svelte gap_buffer_rust gap_buffer_seph gap_buffer_automerge line_gap_svelte line_gap_rust line_gap_seph line_gap_automerge rope_svelte rope_rust rope_seph rope_automerge
hyperfine './gap_buffer_svelte' './rope_svelte' './line_gap_svelte' --export-markdown svelte.md
hyperfine './gap_buffer_rust' './rope_rust' './line_gap_rust' --export-markdown rust.md
hyperfine './gap_buffer_seph' './rope_seph' './line_gap_seph' --export-markdown seph.md
hyperfine './gap_buffer_automerge' './rope_automerge' './line_gap_automerge' --export-markdown automerge.md
gap_buffer_svelte:
mlton gap_buffer_svelte.mlb
gap_buffer_rust:
mlton gap_buffer_rust.mlb
gap_buffer_seph:
mlton gap_buffer_seph.mlb
gap_buffer_automerge:
mlton gap_buffer_automerge.mlb
line_gap_svelte:
mlton line_gap_svelte.mlb
line_gap_rust:
mlton line_gap_rust.mlb
line_gap_seph:
mlton line_gap_seph.mlb
line_gap_automerge:
mlton line_gap_automerge.mlb
rope_svelte:
mlton rope_svelte.mlb
rope_rust:
mlton rope_rust.mlb
rope_seph:
mlton rope_seph.mlb
rope_automerge:
mlton rope_automerge.mlb
clean:
rm -f gap_buffer_svelte gap_buffer_rust gap_buffer_seph gap_buffer_automerge
rm -f line_gap_svelte line_gap_rust line_gap_seph line_gap_automerge
rm -f rope_svelte rope_rust rope_seph rope_automerge
rm -f svelte.md rust.md seph.md automerge.md

View File

@@ -0,0 +1,13 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
../data-sets/automerge.sml
end
transaction.sml
run.sml
../src/gap_buffer.sml
gap_buffer_automerge.sml

View File

@@ -0,0 +1,13 @@
structure GapBufferAutomerge: TRANSACTION =
struct
type t = GapBuffer.t
val empty = GapBuffer.empty
val insert = GapBuffer.insert
val delete = GapBuffer.delete
val toString = GapBuffer.toString
val txns = AutomergePaper.txns
end
structure Main = Run(GapBufferAutomerge)
val _ = Main.run ()

View File

@@ -0,0 +1,13 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
../data-sets/rust.sml
end
transaction.sml
run.sml
../src/gap_buffer.sml
gap_buffer_rust.sml

View File

@@ -0,0 +1,13 @@
structure GapBufferRust: TRANSACTION =
struct
type t = GapBuffer.t
val empty = GapBuffer.empty
val insert = GapBuffer.insert
val delete = GapBuffer.delete
val toString = GapBuffer.toString
val txns = RustCode.txns
end
structure Main = Run(GapBufferRust)
val _ = Main.run ()

View File

@@ -0,0 +1,13 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
../data-sets/seph.sml
end
transaction.sml
run.sml
../src/gap_buffer.sml
gap_buffer_seph.sml

View File

@@ -0,0 +1,13 @@
structure GapBufferSeph: TRANSACTION =
struct
type t = GapBuffer.t
val empty = GapBuffer.empty
val insert = GapBuffer.insert
val delete = GapBuffer.delete
val toString = GapBuffer.toString
val txns = SephBlog.txns
end
structure Main = Run(GapBufferSeph)
val _ = Main.run ()

View File

@@ -0,0 +1,13 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
../data-sets/svelte.sml
end
transaction.sml
run.sml
../src/gap_buffer.sml
gap_buffer_svelte.sml

View File

@@ -0,0 +1,13 @@
structure GapBufferSvelete: TRANSACTION =
struct
type t = GapBuffer.t
val empty = GapBuffer.empty
val insert = GapBuffer.insert
val delete = GapBuffer.delete
val toString = GapBuffer.toString
val txns = SvelteComponent.txns
end
structure Main = Run(GapBufferSvelete)
val _ = Main.run ()

View File

@@ -0,0 +1,13 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
../data-sets/automerge.sml
end
transaction.sml
run.sml
../src/line_gap.sml
line_gap_automerge.sml

View File

@@ -0,0 +1,13 @@
structure LineGapAutomerge: TRANSACTION =
struct
type t = LineGap.t
val empty = LineGap.empty
val insert = LineGap.insert
val delete = LineGap.delete
val toString = LineGap.toString
val txns = AutomergePaper.txns
end
structure Main = Run(LineGapAutomerge)
val _ = Main.run ()

View File

@@ -0,0 +1,13 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
../data-sets/rust.sml
end
transaction.sml
run.sml
../src/line_gap.sml
line_gap_rust.sml

View File

@@ -0,0 +1,13 @@
structure LineGapRust: TRANSACTION =
struct
type t = LineGap.t
val empty = LineGap.empty
val insert = LineGap.insert
val delete = LineGap.delete
val toString = LineGap.toString
val txns = RustCode.txns
end
structure Main = Run(LineGapRust)
val _ = Main.run ()

View File

@@ -0,0 +1,13 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
../data-sets/seph.sml
end
transaction.sml
run.sml
../src/line_gap.sml
line_gap_seph.sml

View File

@@ -0,0 +1,13 @@
structure LineGapSeph: TRANSACTION =
struct
type t = LineGap.t
val empty = LineGap.empty
val insert = LineGap.insert
val delete = LineGap.delete
val toString = LineGap.toString
val txns = SephBlog.txns
end
structure Main = Run(LineGapSeph)
val _ = Main.run ()

View File

@@ -0,0 +1,13 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
../data-sets/svelte.sml
end
transaction.sml
run.sml
../src/line_gap.sml
line_gap_svelte.sml

View File

@@ -0,0 +1,13 @@
structure LineGapSvelete: TRANSACTION =
struct
type t = LineGap.t
val empty = LineGap.empty
val insert = LineGap.insert
val delete = LineGap.delete
val toString = LineGap.toString
val txns = SvelteComponent.txns
end
structure Main = Run(LineGapSvelete)
val _ = Main.run ()

View File

@@ -0,0 +1,13 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
../data-sets/automerge.sml
end
transaction.sml
run.sml
../src/tiny_rope.sml
rope_automerge.sml

View File

@@ -0,0 +1,13 @@
structure RopeAutomerge: TRANSACTION =
struct
type t = TinyRope.t
val empty = TinyRope.empty
val insert = TinyRope.insert
val delete = TinyRope.delete
val toString = TinyRope.toString
val txns = AutomergePaper.txns
end
structure Main = Run(RopeAutomerge)
val _ = Main.run ()

View File

@@ -0,0 +1,13 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
../data-sets/rust.sml
end
transaction.sml
run.sml
../src/tiny_rope.sml
rope_rust.sml

View File

@@ -0,0 +1,13 @@
structure RopeRust: TRANSACTION =
struct
type t = TinyRope.t
val empty = TinyRope.empty
val insert = TinyRope.insert
val delete = TinyRope.delete
val toString = TinyRope.toString
val txns = RustCode.txns
end
structure Main = Run(RopeRust)
val _ = Main.run ()

View File

@@ -0,0 +1,13 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
../data-sets/seph.sml
end
transaction.sml
run.sml
../src/tiny_rope.sml
rope_seph.sml

View File

@@ -0,0 +1,13 @@
structure RopeSeph: TRANSACTION =
struct
type t = TinyRope.t
val empty = TinyRope.empty
val insert = TinyRope.insert
val delete = TinyRope.delete
val toString = TinyRope.toString
val txns = SephBlog.txns
end
structure Main = Run(RopeSeph)
val _ = Main.run ()

View File

@@ -0,0 +1,13 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
../data-sets/svelte.sml
end
transaction.sml
run.sml
../src/tiny_rope.sml
rope_svelte.sml

View File

@@ -0,0 +1,13 @@
structure RopeSvelte: TRANSACTION =
struct
type t = TinyRope.t
val empty = TinyRope.empty
val insert = TinyRope.insert
val delete = TinyRope.delete
val toString = TinyRope.toString
val txns = SvelteComponent.txns
end
structure Main = Run(RopeSvelte)
val _ = Main.run ()

23
brolib-sml/bench/run.sml Normal file
View File

@@ -0,0 +1,23 @@
functor Run(Txn: TRANSACTION) =
struct
local
fun folder ((pos, delNum, insStr), buffer) =
let
val buffer =
if delNum > 0 then Txn.delete (pos, delNum, buffer) else buffer
in
if String.size insStr > 0 then Txn.insert (pos, insStr, buffer)
else buffer
end
in
fun runTxns () =
Vector.foldl folder Txn.empty Txn.txns
end
fun run () =
let
val buffer = runTxns ()
in
()
end
end

View File

@@ -0,0 +1,9 @@
signature TRANSACTION =
sig
type t
val empty: t
val insert: int * string * t -> t
val delete: int * int * t -> t
val toString: t -> string
val txns : (int * int * string) vector
end