spotlib

Useful functions for OCaml programming used by @camlspotter
README

Yet another extension of OCaml standard library.

Module name convension

  • X.Open: Recommended to open it when X is used

  • X.Pervasives: They are included in Spotlib.Spot. Opening Spotlib.Spot make them available.

Function name convension

Functions of stdlib are kept as they are. Only the exception is the conversions of non tail recursions to tail recursions.

Tail recursion

Non tail recursive functions in stdlib may be replaced by tail recursive equivalents. In that case, the original functions xxx in stdlib should be accessible by xxx_ntr.

Exception

Some functions xxx do not raise exceptions even for strange inputs.
xxx_exn may throw exceptions for the strange inputs.

For example, List.take 10 [] = [] following the behaviour of Haskell's take.
take_exn throws Invalid_argument "List.take" instead.

Option

Many stdlib functions xxx throw exceptions Not_found when searching fails.
xxx_opt returns None instead.

Default

Many stdlib functions may raise exceptions for some inputs.
xxx_def never throws exceptions for such inputs.
Ex. String.sub and String.sub_default:
String.sub "hello" 3 5 throws an exception, but
String.sub_default "hello" 3 5 = "lo".

Function type convension

  • No labels for basic functions. Proposes to use flip, flip2... instead.

Install
Published
20 Jul 2022
Authors
Sources
spotlib-4.2.0.tar.gz
md5=b5b115479074c30364c325179442cadb
sha512=3fc14b1d4dc39121ec87e90e53eff197446e07f3fb1cfdd26b715175b5e3cb9982f9206a30a35de8d715f9223617668bd5014ba13ee6a1fb0d185d9cba92f6df
Dependencies
ppx_test
>= "1.8.0"
ocaml
>= "4.08.0" & < "5.0"
dune
>= "2.0"
Reverse Dependencies