lue-bird / elm-morph / Array.Morph

Morph for an elm/core Array element

alter

each : MorphIndependently (beforeToNarrow -> Result (Morph.ErrorWithDeadEnd deadEnd) narrow) (beforeToBroad -> broad) -> MorphIndependently (Array beforeToNarrow -> Result (Morph.ErrorWithDeadEnd deadEnd) (Array narrow)) (Array beforeToBroad -> Array broad)

Morph all elements. On the narrowing side all narrowed values must be Ok for it to not result in a Morph.Error

If the element Morph is OneToOne, each will always succeed with the type knowing it does

transform

list : MorphIndependently (List narrowElement -> Result error_ (Array narrowElement)) (Array broadElement -> List broadElement)

Morph.OneToOne from a List

import Array
import Morph

[ 0, 1, 2, 3 ]
    |> Morph.mapTo Array.Morph.list
--> Array.fromList [ 0, 1, 2, 3 ]

Inverse of List.Morph.array

stack : MorphIndependently (Emptiable (Stacked narrowElement) possiblyOrNever_ -> Result error_ (Array narrowElement)) (Array broadElement -> Emptiable (Stacked broadElement) Possibly)

Morph.OneToOne from a stack

import Morph
import Array
import Stack

Stack.topBelow 0 [ 1, 2, 3 ]
    |> Morph.mapTo Array.Morph.stack
--> Array.fromList [ 0, 1, 2, 3 ]

Inverse of Stack.Morph.array

arraySized : MorphIndependently (ArraySized narrowElement narrowRange_ -> Result error_ (Array narrowElement)) (Array broadElement -> ArraySized broadElement (N.Min (N.Up0 broadX_)))

Morph.OneToOne from an ArraySized

import ArraySized
import Array
import Morph

ArraySized.l4 0 1 2 3
    |> Morph.mapTo Array.Morph.arraySized
--> Array.fromList [ 0, 1, 2, 3 ]

Inverse of ArraySized.Morph.array

string : MorphOrError (Array Char) String error_

Morph.OneToOne from a String to Array Char

import Array
import Morph

"0123"
    |> Morph.mapTo Array.Morph.string
--> Array.fromList [ '0', '1', '2', '3' ]

Inverse of String.Morph.array

value : Value.Morph.Internal.MorphValue element -> Value.Morph.Internal.MorphValue (Array element)

Array MorphValue