@@ -8,7 +8,51 @@ aliases = ["/docs/learn/hoon/hoon-tutorial/molds/"]
8A mold is an idempotent function that coerces a [noun](/docs/glossary/noun/) to
8A mold is an idempotent function that coerces a [noun](/docs/glossary/noun/) to
9be of a specific type or crashes.
9be of a specific type or crashes.
12+The simplest molds to understand are arms of cores created with `+$`
15++$ height [feet=@ud inches=@ud]
18+A mold is compiled to a gate that takes in any noun and produces a typed value, or crashes:
22+:: produces [feet=5 inches=11]
29+To coerce using a gate, it's good practice to use the `;;` rune, which can parse inline molds without requiring a comma:
34+:: produces [feet=5 inches=11]
37+;;([feet=@ud inches=@ud] [5 11])
38+:: produces [feet=5 inches=11]
42+Without using `;;`, you would have to start the mold definition with a comma in order for it to be parsed as a mold, not just as a pair of gates with faces on them:
46+(,[feet=@ud inches=@ud] [5 11])
47+:: produces [feet=5 inches=11]
50+([feet=@ud inches=@ud] [5 11])
51+:: compiler error, can't find $ at axis 2 because this is a pair, not a mold
11−`|$` is a new rune as of the writing of this document so you may see this spelled in slightly different way if you don't have the latest version of `hoon.hoon`. `|$` is the mold builder rune which takes a list of molds and produces a mold.
55+`|$` is the mold builder rune which takes a list of molds and produces a mold.
13`|$` implements [parametric
57`|$` implements [parametric
14polymorphism](https://en.wikipedia.org/wiki/Parametric_polymorphism) in Hoon,
58polymorphism](https://en.wikipedia.org/wiki/Parametric_polymorphism) in Hoon,