榆树"implies"函数
Elm "implies" function
我正在寻找执行以下操作的 Elm 函数:
if e then
Just a
else
Nothing
例如,我正在寻找可以像这样使用的运算符 (=>) : Bool -> a -> Maybe a
(二元函数也可以)
(x == 42) => "yes"
如果 x == 42
将 return Just "yes"
,否则将 Nothing
。
显然,我可以使用 if-then-else
来完成同样的事情,但我想知道是否已经存在这样的功能。
Elm Fancy Search tool is great for this kind of search. You can type in a function signature or name and see where it is used across all packages listed on package.elm-lang.org.
目前,that function signature 存在于函数名称 when
下的两个包中:
- krisajenkins/elm-exts/27.4.0: Exts.Maybe.when:当
test
return为真时,returnJust value
,否则returnNothing
.
- Gizra/elm-essentials/1.2.0: Gizra.Maybe.when:如果条件为
True
,则创建Just a
,否则Nothing
我正在寻找执行以下操作的 Elm 函数:
if e then
Just a
else
Nothing
例如,我正在寻找可以像这样使用的运算符 (=>) : Bool -> a -> Maybe a
(二元函数也可以)
(x == 42) => "yes"
如果 x == 42
将 return Just "yes"
,否则将 Nothing
。
显然,我可以使用 if-then-else
来完成同样的事情,但我想知道是否已经存在这样的功能。
Elm Fancy Search tool is great for this kind of search. You can type in a function signature or name and see where it is used across all packages listed on package.elm-lang.org.
目前,that function signature 存在于函数名称 when
下的两个包中:
- krisajenkins/elm-exts/27.4.0: Exts.Maybe.when:当
test
return为真时,returnJust value
,否则returnNothing
. - Gizra/elm-essentials/1.2.0: Gizra.Maybe.when:如果条件为
True
,则创建Just a
,否则Nothing