elm-community / intdict / IntDict.Safe

Safe API wrappers for IntDicts build and query operators to prevent integer overflows with JavaScripts number type.

Prior to delegating to their 'unsafe' equivalent, these functions verify the validity of the key via IntDict.isValidKey.

Return type


type InvalidKey
    = InvalidKey

An error type signaling an invalid key.


type alias SafeKeyResult a =
Result InvalidKey a

A value of this type is returned by all functions in this module. See the core libraries' Result documentation for how to cope with it.

Build

safeInsert : Basics.Int -> v -> IntDict v -> SafeKeyResult (IntDict v)

Version of IntDict.insert that validates the key.

safeUpdate : Basics.Int -> (Maybe v -> Maybe v) -> IntDict v -> SafeKeyResult (IntDict v)

Version of IntDict.update that validates the key.

safeRemove : Basics.Int -> IntDict v -> SafeKeyResult (IntDict v)

Version of IntDict.remove that validates the key.

Query

safeMember : Basics.Int -> IntDict v -> SafeKeyResult Basics.Bool

Version of IntDict.member that validates the key.

safeGet : Basics.Int -> IntDict v -> SafeKeyResult (Maybe v)

Version of IntDict.get that validates the key.