Rerouted (retagged, needs approval). The tag now points at a different commit than when this version was published. The Lamdera package server serves a copy recovered from https://github.com/lue-bird/elm-typesafe-array.
What we checked: Tag 7.1.0 is still on github.com/lue-bird/elm-typesafe-array; its commit c17a96304817 is from 2021-05-03 17:31 UTC, after the version was published (2021-05-03 17:29 UTC); elm.json is byte-identical to package.elm-lang.org's; the exposed modules match docs.json; the zip's SHA-1 is not the published one and nothing else confirms its contents.
We could not verify this copy against what was published, so the Lamdera compiler asks before using it (y/n). Without a terminal, as in CI, it stops with an error unless approved:
lamdera make --auto-approve-package-rerouting approves rerouted versions for that run,LAMDERA_AUTO_APPROVE_PACKAGE_REROUTING=1 does the same for every run in that environment,LAMDERA_CACHE=off skips the Lamdera package server altogether: packages come from package.elm-lang.org and GitHub only, as with elm, and a rerouted version then fails to download.Details · package.elm-lang.org's zip: https://github.com/lue-bird/elm-typesafe-array/zipball/7.1.0/
If the maximum length is a type variable,
first :
Arr (In (Nat1Plus orHigherMin) max) element
-> elementuse these operations instead of the ones in Arr or InArr
Kick out the element at an index in a direction.
removeLast arrWithAtLeast1Element =
arrWithAtLeast1Element
|> MinArr.removeAt nat0 LastToFirstPut a new element at an index in a direction.
arrWithAtLeast5Elements
|> MinArr.insertAt nat0 FirstToLast
"becomes the first"
--> : Arr (Min Nat6) StringAppend an Arr (In ...).
Arr.from3 1 2 3
|> MinArr.extend nat3 arrWithAtLeast3Elements
--> : Arr (Min Nat6) ...Elements after a certain number of elements from one side.
withAtLeast6Elements
|> Arr.drop nat2 LastToFirst
--> : Arr (Min Nat4) ...Compare the length to an exact Nat (ArgN ...).
Is it greater, less or equal?
min ensures that the Nat (ArgN ...) is bigger than the minimum length.
convertUserArguments :
String
-> Result String (Arr (Only Nat3))
convertUserArguments =
String.words
>> Array.fromList
>> Arr.fromArray
>> MinArr.isLength nat3
{ min = nat0 }
{ equal = Ok
, less =
\less ->
Err
("I need 3 arguments, but there are only "
++ String.fromInt (val (Arr.length less))
++ "."
)
, greater =
\more ->
Err
("I need exact 3 arguments, so "
++ String.fromInt (val (Arr.length more))
++ " is too much."
)
}Compare the length to an exact Nat (ArgN ...).
Is it equalOrGreater or less?
min ensures that the lower bound is bigger than the minimum length.
convertUserArguments :
String
-> Result String (Arr (Min Nat3))
convertUserArguments =
String.words
>> Array.fromList
>> Arr.fromArray
>> MinArr.isLengthAtLeast nat3
{ min = nat0 }
{ equalOrGreater = Ok
, less =
\less ->
Err
("I need at least 3 arguments, but there are only "
++ String.fromInt (val (Arr.length less))
++ "."
)
}Is the length
equalOrLess than an upper bound or
greater?
min ensures that the upper bound is greater than the minimum length.
-- only up to 50 tags
tag : Arr (In min Nat50) String -> a -> Tagged a
tagIfValidTags : Array String -> a -> Maybe (Tagged a)
tagIfValidTags array value =
array
|> Arr.fromArray
|> MinArr.isLengthAtMost nat50
{ equalOrLess = tag value >> Just
, greater = \_ -> Nothing
}Convert an exact Arr (In min ...) to a Nat (Min min).
between4And10Elements |> MinArr.value
--> : Arr (Min Nat4) ...There is only 1 situation you should use this.
To make these the same type.
[ atLeast1Element, between1And10Elements ]Elm complains:
But all the previous elements in the list are
Arr (Min Nat1) ...
[ atLeast1Element
, between1And10Elements |> MinArr.value
]A Codec to serialize Arrs with a minimum amount of elements.
import Serialize
-- we can't start if we have no worlds to choose from!
serializeSaves :
Serialize.Codec
String
(Arr (Min Nat1) World)
serializeSaves =
MinArr.serialize nat1 serializeWorld
encode : Arr (In (Nat1Plus minMinus1) max) World -> Bytes
encode =
MinArr.value
>> Serialize.encodeToBytes serializeSaves
decode :
Bytes
->
Result
(Serialize.Error String)
(Arr (Min Nat1) World)
decode =
Serialize.decodeFromBytes serializeSaves
Put a new element after the others.