-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
fmt
and pp
to Map
, Set
, Ordmap
, and Ordset
Add formatters and pretty printers to the map and set collections, using associative list and list syntactic representations, respectively. Sort the unordered map/set contents to avoid unnecessary output instability.
- Loading branch information
Jason Evans
committed
Apr 13, 2022
1 parent
cc2cacc
commit 8dcbc94
Showing
68 changed files
with
212 additions
and
123 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fmt (of_klist []) -> [] | ||
fmt (of_klist [0]) -> [(0, 0)] | ||
fmt (of_klist [0; 1]) -> [(0, 0); (1, 100)] | ||
fmt (of_klist [0; 2]) -> [(0, 0); (2, 200)] | ||
fmt (of_klist [2; 3]) -> [(2, 200); (3, 300)] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
open! Basis.Rudiments | ||
open! Basis | ||
open MapTest | ||
open Map | ||
|
||
let test () = | ||
let rec fn = function | ||
| [] -> () | ||
| l :: lists' -> begin | ||
let map = of_klist l in | ||
File.Fmt.stdout | ||
|> Fmt.fmt "fmt (of_klist " | ||
|> (List.pp Uns.pp) l | ||
|> Fmt.fmt ") -> " | ||
|> fmt Uns.pp map | ||
|> Fmt.fmt "\n" | ||
|> ignore; | ||
fn lists' | ||
end | ||
in | ||
(* NB: [0; 1] and [0; 2] collide. This is because we're using UnsTestCmper to get stable test | ||
* output; the hashing results from all but the last binding hashed are discarded. *) | ||
let lists = [ | ||
[]; | ||
[0L]; | ||
[0L; 1L]; | ||
[0L; 2L]; | ||
[2L; 3L] | ||
] in | ||
fn lists | ||
|
||
let _ = test () |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fmt (of_klist []) -> [] | ||
fmt (of_klist [0]) -> [(0, 0)] | ||
fmt (of_klist [0; 1]) -> [(0, 0); (1, 100)] | ||
fmt (of_klist [0; 2]) -> [(0, 0); (2, 200)] | ||
fmt (of_klist [2; 3]) -> [(2, 200); (3, 300)] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
open! Basis.Rudiments | ||
open! Basis | ||
open OrdmapTest | ||
open Ordmap | ||
|
||
let test () = | ||
let rec fn = function | ||
| [] -> () | ||
| l :: lists' -> begin | ||
let ordmap = of_klist l in | ||
File.Fmt.stdout | ||
|> Fmt.fmt "fmt (of_klist " | ||
|> (List.pp Uns.pp) l | ||
|> Fmt.fmt ") -> " | ||
|> fmt Uns.pp ordmap | ||
|> Fmt.fmt "\n" | ||
|> ignore; | ||
fn lists' | ||
end | ||
in | ||
let lists = [ | ||
[]; | ||
[0L]; | ||
[0L; 1L]; | ||
[0L; 2L]; | ||
[2L; 3L] | ||
] in | ||
fn lists | ||
|
||
let _ = test () |
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
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
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
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
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
Oops, something went wrong.