This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.

Gizra.Maybe

A module with some useful Maybe utilities.

when : Bool -> a -> Maybe a

Create a Just a if condition is True, otherwise Nothing

"something" |> when True --> Just "something"

"something" |> when False --> Nothing
module Gizra.Maybe exposing (when)

{-| A module with some useful `Maybe` utilities.

@docs when

-}


{-| Create a `Just a` if condition is `True`, otherwise `Nothing`

    "something" |> when True --> Just "something"

    "something" |> when False --> Nothing

-}
when : Bool -> a -> Maybe a
when condition value =
    if condition then
        Just value
    else
        Nothing