lue-bird/elm-morph/1.1.0

NOTE: the latest version is 3.0.1

Array.Morph

MorphIndependently
(beforeToNarrow -> Result (ErrorWithDeadEnd deadEnd) narrow)
(beforeToBroad -> broad)
-> MorphIndependently
( Array beforeToNarrow
-> Result (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

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

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

MorphIndependently
( ArraySized narrowElement narrowRange_
-> Result error_ (Array narrowElement)
)
( Array broadElement
-> ArraySized broadElement (Min (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 : MorphValue element -> MorphValue (Array element)