Try Install Learn Blog API Packages GitHub

Built-in Types

Mint comes with several built-in types. These are used in control expressions: Promise , Result , Void and Never. The Maybe type represents a nillable value.


The promise type represents a JavaScript promise - an asynchronous computational task that might fail.

In Mint promises have two parameters Promise(error, result) :

  • error - the type of the error
  • result - the type of the result

A good example is a HTTP request which in Mint looks like this:

Promise(Http.ErrorResponse, Http.Response)

where Http.ErrorResponse is a record containing information about the error that happened while Http.Response is a record containing the response of the request.

Promises are used in a sequence and parallel expressions.


The result type, represents a synchronous task that might fail. It is defined as an enum:

enum Result(error, value) {

In Mint, results have two parameters Result(error, value):

  • error - the type of the error
  • value - the type of the value in the Ok case

For example, converting a String to a Number:

  • If the conversion fails we get an error:
    |> Number.fromString()
    |> Maybe.toResult("Conversion failed.")
    |> Result.isError() /* true */
  • If the conversion succeeds we get a value
    |> Number.fromString()
    |> Maybe.toResult("Conversion failed.")
    |> Result.isOk() /* true */

Results are used in sequence , parallel and try expressions.


The void type represents an expression which cannot have any value.

Void can only be explicitly returned with the void keyword.


The never type is used to describe tasks (promises or results) that can never fail. For example, here is the type of task that can never fail: Promise(Never, String)

These tasks don't need to be caught in sequence , parallel and try expressions.


The maybe type represents a value which may or may not exist. It's defined as an enum:

enum Maybe(value) {

For example here is a user who may or may not have a car:

record Car {
  type : String,
  engine : String

record User {
  name : String,
  car : Maybe(Car)