Skip to content
This repository was archived by the owner on Aug 14, 2019. It is now read-only.

Conversation

@joemfb
Copy link
Contributor

@joemfb joemfb commented May 29, 2019

after:

> ((map) [[1 2] ~ [[3 4] ~ ~]])
{[p=1 q=2] [p=3 q=4]}
> ((map) [[1 2] [[3 4] ~ ~] ~])
ford: %ride failed to execute:

before:

> ((map) [[1 2] ~ [[3 4] ~ ~]])
{[p=1 q=2] [p=3 q=4]}
> ((map) [[1 2] [[3 4] ~ ~] ~])
{[p=3 q=4] [p=1 q=2]}

much before:

#311

I had to move these mold/mold-builder definitions so that the +in and +by cores are available to them. Note that the section labels are still wrong, although somewhat less so. I think that's out of scope for this PR, as the labels are wrong in many parts of hoon.hoon.

Copy link
Contributor

@jtobin jtobin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@philipcmonk philipcmonk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! When does the validator get run? Only on clam, or also on cast? Can you take a well-formed map, perturb it maliciously, and cast the result to map?

Approving because regardless of the above question, this is better than what we had.

@belisarius222
Copy link

belisarius222 commented May 29, 2019 via email

@joemfb
Copy link
Contributor Author

joemfb commented May 29, 2019

Right, molds (specs) only exist at compile time. ^-(spec hoon) desugars to ^+(*spec hoon), so only the bunt of the mold is used for casting -- the validation function is not involved (or even available).

Some more examples:

> ((set) [2 [1 ~ ~] ~])
{1 2}
> ((set) [2 ~ [1 ~ ~]])
ford: %ride failed to execute:

Note also that the validation is applied recursively ((jug) is (map * (set))):

> `*`(my [1 (sy 2 3 ~)] [4 (sy 5 6 ~)] ~)
[[4 6 [5 0 0] 0] [[1 2 0 3 0 0] 0 0] 0]
> ((jug) [[4 [6 [5 ~ ~] ~]] [[1 [2 ~ [3 ~ ~]]] ~ ~] ~])
{[p=1 q={2 3}] [p=4 q={5 6}]}
> ((jug) [[4 [6 [5 ~ ~] ~]] ~ [[1 [2 ~ [3 ~ ~]]] ~ ~]])
ford: %ride failed to execute:
> ((jug) [[4 [6 ~ [5 ~ ~]]] [[1 [2 ~ [3 ~ ~]]] ~ ~] ~])
ford: %ride failed to execute:

@philipcmonk
Copy link
Contributor

Makes sense.

Is there a reason why we don't verify the vertical ordering of a qeu?

@joemfb
Copy link
Contributor Author

joemfb commented May 29, 2019

I guess nobody has taken the time to write +apt:to. I think it would be something like this:

++  apt
  ^-  ?
  ?~  a  &
  |-  ^-  ?
  ?~  l.a  &
  ?~  r.a  &
  &((mor n.l.a n.r.a) $(a l.a) $(a r.a))

@jtobin
Copy link
Contributor

jtobin commented May 30, 2019

(extra 👍 for the tests)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants