elm-community/basics-extra/2.1.1

NOTE: this package is not compatible with Elm 0.19.1

Basics.Extra

Additional basic functions.

Tuples

(=>) : a -> b -> ( a, b )

A shorthand for writing 2-tuples. Very commonly used when expressing key/value pairs in CSS or Json encoders.

swap : ( a, b ) -> ( b, a )

Swaps the elements in a pair.

swap ( 1, 2 ) == ( 2, 1 )

Numbers

The maximum safe value for an integer, defined as 2^53 - 1. Anything larger than that and behaviour becomes mathematically unsound.

(maxSafeInteger + 1) == (maxSafeInteger + 2)
    == True

The minimum safe value for an integer, defined as -(2^53 - 1). Anything smaller than that, and behaviour becomes mathematically unsound.

(minSafeInteger - 1) == (minSafeInteger - 2)
    == True
isSafeInteger : Int -> Bool

Checks if a given integer is within the safe range, meaning it is between -(2^53 - 1) and 2^53 - 1.

isSafeInteger 5 == True
isSafeInteger maxSafeInteger == True
isSafeInteger (maxSafeInteger + 1) == False