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 set to a specific value (also in ArgOnly),
-- only up to 50 tags
tag : Arr (In min Nat50) String -> a -> Tagged ause these operations instead of the ones in Arr or MinArr.
Append the elements of another Arr (In ...).
Append the elements of an Arr (Only ...).
Kick an element out of an Arr at a given index in a direction.
Use MinArr.push, if the max isn't known to be a certain value.
Elements after a certain number of elements from one side.
with6To10Elements
|> Arr.drop nat2 LastToFirst
--> : Arr (In Nat4 (Nat10Plus a)) ...Compared to a range from a lower to an upper bound, is the length
inRange
greater than the upper bound or
less than the lower bound?
min ensures that the lower bound is greater than the minimum length.
chooseFormation :
Arr (In Nat0 Nat50) Character
-> Formation
chooseFormation characters =
characters
|> InArr.isLengthInRange nat10
nat20
{ min = nat0 }
{ equal = SpecialAttack
, less = Retreat
, more = Fight
}
type Formation
= SpecialAttack (Arr (In Nat10 Nat20) Character)
| Retreat (Arr (In Nat0 Nat9) Character)
| Fight (Arr (In Nat21 Nat50) Character)Compare the length to an exact Nat (ArgN ...) length.
Are there more, less or an equal amount of elements?
min ensures that the Nat (ArgN ...) is greater than the minimum length.
chooseFormation :
Arr (In Nat0 Nat50) Character
-> Formation
chooseFormation characters =
characters
|> InArr.isLength nat7
{ min = nat0 }
{ equal = SpecialAttack
, less = Retreat
, more = Fight
}
type Formation
= SpecialAttack (Arr (Only Nat7) Character)
| Retreat (Arr (In Nat0 Nat6) Character)
| Fight (Arr (In Nat8 Nat50) Character)Is the length
equalOrGreater than a lower bound or
less?
min ensures that the lower bound is greater than the minimum length.
first5 :
Arr (In min max) element
-> Maybe (Arr (In Nat5 max) element)
first5 =
MinArr.lowerMinLength nat0
>> MinArr.isLengthAtLeast nat5
{ min = nat0 }
{ less = \_ -> Nothing
, equalOrGreater = Just
}Is the length
equalOrLess than a upper bound or
greater?
min ensures that the upper bound is greater than the minimum length.
-- at least 3 and only up to 50 tags
tag :
Arr (In (Nat3Plus orHigherMin) Nat50) String
-> a
-> Tagged a
tagIfValidTags :
Arr (In (Nat3Plus orHigherMin) max)
-> a
-> Maybe (Tagged a)
tagIfValidTags array value =
array
|> Arr.fromArray
|> InArr.isLengthAtMost nat50
{ equalOrLess = tag value >> Just
, greater = \_ -> Nothing
}A Codec to serialize Arrs within a minimum & maximum length.
import Serialize
serialize10To15Ints :
Serialize.Codec
String
(Arr (In Nat10 (Nat15Plus a)) Int)
serialize10To15Ints =
InArr.serialize Serialize.int nat10 nat15
encode :
Arr (In (Nat10Plus orHigherMin) Nat15) Int
-> Bytes
encode =
InNat.value
>> Serialize.encodeToBytes serialize10To15Ints
decode :
Bytes
->
Result
(Serialize.Error String)
(Arr (In Nat10 (Nat15Plus a) Int))
decode =
Serialize.decodeFromBytes serialize10To15IntsFor decoded Arrs with a length outside of the expected bounds, the Result is an error message.
Put a new element after the others.