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

NonZero

NonZero numbers are numbers excluding zero. Because the constructor for NonZero is not exported, you can be confident that if you are using a NonZero, then its NonZero.

type NonZero number = NonZero number
fromNum : number -> Maybe (NonZero number)
toNum : NonZero number -> number
module NonZero exposing (NonZero, fromNum, toNum)

{-|
NonZero numbers are numbers excluding zero.
Because the constructor for `NonZero` is not exported, you can be
confident that if you are using a `NonZero`, then its `NonZero`.

@docs NonZero, fromNum, toNum
-}


{-| -}
type NonZero number
    = NonZero number


{-| -}
fromNum : number -> Maybe (NonZero number)
fromNum x =
    if x == 0 then
        Nothing
    else
        Just (NonZero x)


{-| -}
toNum : NonZero number -> number
toNum (NonZero x) =
    x