モナドに関する処理を集めたユーティリティモジュール.
Copyright (c) 2013-2014 DWANGO Co., Ltd. All Rights Reserved.
maybe() = {just, term()} | nothing
なにか or Nothing を格納するデータ構造
maybe_fun() = {just, function()} | nothing
何らかの関数 or Nothing を格納するデータ構造
apply_maybe/3 | MaybeFunが{just, Function}なら apply(Function, ArgList) を実行します. |
maybe/1 | maybe()を作ります. |
maybe_fun/1 | maybe()を作ります. |
apply_maybe(MaybeFun::maybe_fun(), ArgList::[any()], DefaultValue::any()) -> any()
MaybeFunが{just, Function}なら apply(Function, ArgList) を実行します. MaybeFunがnothingならDefaultValue を返します
maybe(Value::term()) -> maybe()
maybe()を作ります.
{just nothing} は作れないので直接作ってください.
maybe_fun(Fun::nothing | function()) -> maybe()
maybe()を作ります.