ucg/docsite/site/content/stdlib/functional.md
Jeremy Wall 2134d79f0d DOCS: Formatting and organization changes.
Additionally:

* Added an overview
* Expanded the docs for the NULL type.
2019-02-25 19:02:23 -06:00

21 lines
787 B
Markdown

+++
title = "Functional operations"
weight = 5
sort_by = "weight"
in_search_index = true
+++
UCG comes with some builtin functional operations.
## Useful functions
* identity - the Identity function. Returns it's argument unchanged.
## Maybe module
Maybe is a monadic style wrapper for values that might be NULL. It provides a several operations for the wrapped value.
* do(op) - runs op which is a function of one argument against the wrapped value if it is not null. Returns the result or NULL wrapped in another maybe.
* is_null() - returns true if the wrapped value is null, false otherwise.
* unwrap() - returns the wrapped value
* expect(msg) - returns the wrapped value if it is not null. Throws a compile error with the user provided message otherwise.