std.result

Modules

Error handling type.

Types

type Result e t = 
    | Err e
    | Ok t

Result represents either success (Ok) or an error (Err)

Values

let unwrap_ok res : forall a e . std.types.Result e a -> a

let unwrap_err res : forall a e . std.types.Result e a -> e

let map_err f res : forall a f e . (e -> f) -> std.types.Result e a -> std.types.Result f a

let eq : forall a e .
    [std.cmp.Eq e] -> [std.cmp.Eq a] -> std.cmp.Eq (std.types.Result e a)

Eq a defines equality (==) on a

let ord : forall a e .
    [std.cmp.Ord e] -> [std.cmp.Ord a] -> std.cmp.Ord (std.types.Result e a)

Ord a defines an ordering on a

let functor : forall e . std.functor.Functor (std.types.Result e)

A Functor represents an action on a parameterized type which does not change the structure with the mapped type.

The following laws should hold:

  • map id == id
  • map (f << g) == map f << map g

let applicative : forall e . std.applicative.Applicative (std.types.Result e)

A Functor with application.

The following laws should hold:

  • wrap id <*> v = v
  • wrap (<<) <> u <> v <> w = u <> (v <*> w)
  • wrap f <*> wrap x = wrap (f x)
  • u <> wrap y = wrap (\g -> g x) <> u

let monad : forall e . std.monad.Monad (std.types.Result e)

A generalised interface for imperatively sequencing actions

let foldable : forall e . std.foldable.Foldable (std.types.Result e)

Operations over a data structure that can be folded which means that a functions gets called on each element to reduce the structure to a single value (Array, List and Map are all Foldable)

let traversable : forall e . std.traversable.Traversable (std.types.Result e)

let show ?e ?t : forall t e .
    [std.show.Show e]
        -> [std.show.Show t]
        -> std.show.Show (std.types.Result e t)

Show a represents a conversion function from a to a readable string.