ilyakooo0/airlock/1.0.1

NOTE: the latest version is 1.1.1

Renamed to iko-soy/airlock. That is where the repository lives now. It has not been published as a package under the new name.

Versions published as ilyakooo0/airlock still install under that name. 4 versions of 4 come from the new location (see their notes).

Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/iko-soy/airlock.

What we checked: The repo moved to github.com/iko-soy/airlock. Rebuilt with git archive from commit 1086ce8d954f of https://github.com/iko-soy/airlock (zip prefix ilyakooo0-airlock-4f76b03/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 c065fca7629d5164933a195740086c32edeaf556.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/ilyakooo0/airlock/zipball/1.0.1/

Ur.Deconstructor

This module provides an API to deconstruct Nouns into arbitrary Elm data structures.

You would parse a [%edit @ cord] like this:

 type alias Edit = {id: Int, text : String}


 (D.cell (D.const D.cord "edit") (D.cell D.bigint D.cord)) |> D.map (\( (), ( id, txt ) ) -> Edit id txt)
type alias Deconstructor a =
Noun -> Maybe a

A Noun deconstructor.

Running a Deconstructor

run : Deconstructor a -> Noun -> Maybe a

Executes a Deconstructor on a Noun.

runBytes : Deconstructor a -> Bytes -> Maybe a

Executes a deconstructor on a jammed Noun.

Higher-order Deconstructors

cell : Deconstructor a -> Deconstructor b -> Noun -> Maybe ( a, b )

Extracts a Cell (pair) of two arbitrary values.

Accepts two arbitrary Deconstructors that form a Cell.

list : Deconstructor a -> Noun -> Maybe (List a)

Extracts a sig-terminated list of arbitrary elements.

The first argument is a Deconstructor of the elements of the list.

oneOf : List (Deconstructor a) -> Deconstructor a

Try to execute all of the Deconstructors in order until one succeeds.

This is especially useful for deconstructing head-tagged unions from Hoon.

const : Deconstructor a -> a -> Noun -> Maybe ()

Asserts that the value should be exactly equal to the second argument.

The first argument is a Deconstructor for the given type.

The second argument is the value to compare with.

This is useful to match on terms when there are multiple possible cases in a head-tagged union.

Mapping a Deconstructor

map : (a -> b) -> Deconstructor a -> Noun -> Maybe b

Maps over the result of the deconstructor.

Numbers

Inta

int : Noun -> Maybe Int

Extracts a 32-bit unsigned Int.

If the Atom is larger than 32 bits the the behaviour is undefined.

signedInt : Deconstructor Int

Extracts a 32-bit signed Int.

If the Atom is larger than 32 bits the the behaviour is undefined.

bigint : Noun -> Maybe BigInt

Extracts a BigInt.

Floats

float32 : Noun -> Maybe Float

Extracts a 32-bit Float.

float64 : Noun -> Maybe Float

Extracts a 64-bit Float.

Strings

cord : Noun -> Maybe String

Extracts a cord.

tape : Deconstructor String

Extracts a tape.

Miscellaneous

bytes : Noun -> Maybe Bytes

Extracts the raw Bytes of an Atom.

sig : Noun -> Maybe ()

Asserts the the Atom should be exactly sig (~).

ignore : Deconstructor ()

Ignore any value.

This is useful when you have a value you don't care about. ignore allows you to just skip the value.

tar : Deconstructor Noun

Extract the raw Noun.

Always succeeds.

lazy : (() -> Deconstructor a) -> Noun -> Maybe a

Maps (applies) a function to all of the values deconstructed.

This is useful when you want to create a data type with extracted values as fields.