Skip to content

Commit 2c849bd

Browse files
committed
Reimplemented AdjacencyList with Map_Ext and Set_Ext
1 parent 93ba4cf commit 2c849bd

5 files changed

+40
-0
lines changed

src/StdlibFp.res

+4
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,7 @@ module Set = Stdlib__Set
7171
module Option = Stdlib__Option
7272
module List = Stdlib__List
7373
module Result = Stdlib__Result
74+
75+
// my extensions
76+
module Serializable = Stdlib__Serializable
77+
module JSONSerializable = Stdlib__JSONSerializable

src/StdlibFp.res.mjs

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ let List;
4343

4444
let Result;
4545

46+
let Serializable;
47+
48+
let JSONSerializable;
49+
4650
export {
4751
Tablecloth,
4852
$$Function,
@@ -65,5 +69,7 @@ export {
6569
Option,
6670
List,
6771
Result,
72+
Serializable,
73+
JSONSerializable,
6874
}
6975
/* No side effect */

src/Stdlib__Map_Ext.res

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ module JSONSerializable = Stdlib__JSONSerializable
33

44
module type S = {
55
type key
6+
7+
// these types are from Core__Map
68
type t<'k, 'v>
79
let make: unit => t<_, 'v>
810

@@ -32,6 +34,7 @@ module type T = {
3234

3335
module MakeWithPrimitive = (T: T): (S with type key = T.t) => {
3436
type key = T.t
37+
3538
type t<'k, 'v> = Map.t<key, 'v>
3639

3740
let make = Map.make
@@ -58,6 +61,7 @@ module MakeWithPrimitive = (T: T): (S with type key = T.t) => {
5861

5962
module Make = (Serializable: Serializable.S): (S with type key = Serializable.t) => {
6063
type key = Serializable.t
64+
6165
type t<'k, 'v> = Map.t<string, 'v>
6266

6367
let make: unit => t<'k, 'v> = Map.make

src/Stdlib__Serializable.res

+7
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,10 @@ module MakeTuple3 = (A: JSONSerializable.S, B: JSONSerializable.S, C: JSONSerial
7373

7474
let fromStringUnsafe = str => str->fromString->Option.getExn
7575
}
76+
77+
module String = {
78+
type t = string
79+
let toString = s => s
80+
let fromString = s => Some(s)
81+
let fromStringUnsafe = s => s
82+
}

src/Stdlib__Serializable.res.mjs

+19
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,31 @@ function MakeTuple3(A) {
7272
});
7373
}
7474

75+
function toString(s) {
76+
return s;
77+
}
78+
79+
function fromString(s) {
80+
return Primitive_option.some(s);
81+
}
82+
83+
function fromStringUnsafe(s) {
84+
return s;
85+
}
86+
87+
let $$String = {
88+
toString: toString,
89+
fromString: fromString,
90+
fromStringUnsafe: fromStringUnsafe
91+
};
92+
7593
let JSONSerializable;
7694

7795
export {
7896
JSONSerializable,
7997
MakeArray,
8098
MakeTuple2,
8199
MakeTuple3,
100+
$$String,
82101
}
83102
/* No side effect */

0 commit comments

Comments
 (0)