Tablecloth
A portable standard library enhancement for Reason and OCaml.
Tablecloth provides an easy-to-use, comprehensive and safe standard library that has the same API for the OCaml and Bucklescript compilers.
open Tablecloth;String.toList("Tablecloth")|> List.filterMap(~f=character =>Char.toCode(character)|> Int.add(1)|> Char.fromCode)|> String.fromList/* "Ubcmfdmpui" */
Easy to learn
Excellent documentation, comprehensive examples and consistent behaviour make Tablecloth efficient to get started withSafe
Banish runtime errors and work effectively with Options and Resultsreason
let name = Some("Kubo");let species = Some("dog");let favoriteGame = None;let bio = Option.({let (name, species) = Option.both(name, species);name ++ " the " ++ "'s favorite game is" ++ (favoriteGame |? "fetch");})
Portable
Works with either the Reason or OCaml syntax, targeting the Bucklescript, Native orjs_of_ocaml
compilersAdvanced
Index operators for Arrays, Maps, Sets and Strings plus binding operators for Options & Results mean your code is concise and expressiveocaml
let nameToSpecies = Map.String.fromList [("Amy", "Ant");("Barry", "Badger");](* Get a value from a Map by its key *)nameToSpecies.Map.?{"Carolyn"} = None(* Extract a Char from a String safely *)"Tablecloth".String.?[1] = Some('a')(* Index into an Array without fear *)[|2;3;5;7|].Array.?(3) = Some(7)