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

Number.Expanded

Expanded Numbers A number that can either be finite or infinite

type Expanded number = Finite number | PosInfinity | NegInfinity

Expanded number can be Positive or Negative Infinity

toExpanded : number -> Expanded number
withDefault : a -> (number -> a) -> Expanded number -> a

Get the value out of Expanded providing a default for the infinite case

withDefaults : a -> a -> (number -> a) -> Expanded number -> a

Get the value out of Expanded providing a default for the infinite cases. First argument is the default for the PosInfinity case, the second is for NegInfinity

map : (number -> number) -> Expanded number -> Expanded number

Not a Functor, but still mappable

module Number.Expanded exposing (..)

{-|
Expanded Numbers
A number that can either be finite or infinite

@docs Expanded, toExpanded, withDefault, withDefaults, map
-}


{-| Expanded number can be Positive or Negative Infinity
-}
type Expanded number
    = Finite number
    | PosInfinity
    | NegInfinity


{-| -}
toExpanded : number -> Expanded number
toExpanded =
    Finite


{-|
Get the value out of `Expanded` providing a default for the infinite case
-}
withDefault : a -> (number -> a) -> Expanded number -> a
withDefault default f card =
    case card of
        Finite x ->
            f x

        _ ->
            default


{-|
Get the value out of `Expanded` providing a default for the infinite cases.
First argument is the default for the `PosInfinity` case, the second is for `NegInfinity`
-}
withDefaults : a -> a -> (number -> a) -> Expanded number -> a
withDefaults posdef negdef f card =
    case card of
        Finite x ->
            f x

        PosInfinity ->
            posdef

        NegInfinity ->
            negdef


{-|
Not a Functor, but still mappable
-}
map : (number -> number) -> Expanded number -> Expanded number
map f card =
    case card of
        Finite x ->
            Finite (f x)

        infinity ->
            infinity