Orasund/elm-static-array/2.1.0

NOTE: the latest version is 3.0.0

StaticArray.Length

This module introduces the Length type. The length type is an integer but its value is known in compile time. This way we can ensure that no index out of bounds error occurs.

Basics

type alias Length n =
Length n

A length represents the length of a static array

import StaticArray


StaticArray.singleton 42
    |> StaticArray.push 7
    |> StaticArray.length
    --> two
one : Length One

Length of an array with one element

plus1 : Length n -> Length (OnePlus n)

Increases the length by one

minus1 : Length (OnePlus n) -> Length n

Decreases the length by one

toInt : Length n -> Int

Converts a length into int

four
    |> toInt
    --> 4

Constructors

two : Length Two

Length of an array with two elements

four : Length Four

Length of an array with four elements

five : Length Five

Length of an array with five elements

eight : Length Eight

Length of an array with eight elements

ten : Length Ten

Length of an array with ten elements

twenty : Length Twenty

Length of an array with twenty elements

Addition

plus2 : Length n -> Length (TwoPlus n)

Increases the length by two

plus4 : Length n -> Length (FourPlus n)

Increases the length by four

plus5 : Length n -> Length (FivePlus n)

Increases the length by five

plus8 : Length n -> Length (EightPlus n)

Increases the length by eight

plus10 : Length n -> Length (TenPlus n)

Increases the length by ten

plus20 : Length n -> Length (TwentyPlus n)

Increases the length by twenty

Subtraction

minus2 : Length (TwoPlus n) -> Length n

Decreases the length by two

minus4 : Length (FourPlus n) -> Length n

Decreases the length by four

minus5 : Length (FivePlus n) -> Length n

Decreases the length by five

minus8 : Length (EightPlus n) -> Length n

Decreases the length by eight

minus10 : Length (TenPlus n) -> Length n

Decreases the length by ten

minus20 : Length (TwentyPlus n) -> Length n

Decreases the length by twenty