Orasund/elm-static-array/2.0.1

NOTE: the latest version is 3.0.0

StaticArray.Length

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

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 a 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 a array with two elements

four : Length Four

Length of a array with four elements

five : Length Five

Length of a array with five elements

eight : Length Eight

Length of a array with eight elements

ten : Length Ten

Length of a array with ten elements

twenty : Length Twenty

Length of a 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