package sugar

  1. Overview
  2. Docs

Conventional module type to define the errors inside a project. This is how Sugar understands the error handling layer of a project.

Like:

module MyError = struct
  type error = Not_found | Invalid_arg of string
end

This module might be used to create blocking or asynchronous error handling layers, using the Sugar functors, like:

module MyResult = Sugar.Result.Make (MyError)

module MyResult2 = Sugar.Promise.Make (Lwt) (MyError)
module MyResult2 = MyResult.For (Lwt)
type t

This type describes the errors of your project. It's one of the main requirements to create a result monad.

If you don't want to specify your errors upfront, you can still use something like unit or string as error type.