Maybe

Maybe a is the FP solution to the problem of null values. It is essentially Either Unit a.

data Maybe a
  = Nothing
  | Just a

Maybe a is the same as Either unimportantType a

PackageType name"Plain English" name
purescript-maybeMaybe aA full or empty box
UsageValues' Representation
Indicates an optional value
  • Nothing - value does not exist
  • Just a - value does exist
Used for error-handling when we don't care about the error (replaces null)
  • Nothing - An error occurred during computation but the error is irrelevant
  • Just a - successful computation returned output.

API visualized:

Maybe API