Elm Exactly

Figuredynamic-basis-eq

Figure 54, Equality of Values, in Section D.4.5 Equality.

  1. If v,v′∈Funv,v'\in\dbFun, then Eq(v,v′)={True,False}\dbEq(v,v')=\{\kw{True},\kw{False}\}.

  2. If vv and v′v' are floats: Eq(v,v′)={True}\dbEq(v,v')=\{\kw{True}\} if neither is NaN and v=v′v=v' (so that +0+0 equals −0-0), and {False}\{\kw{False}\} otherwise.

  3. If vv and v′v' are both Int values, both characters, both strings, both the unit value, both process identifiers, or both boundary values (Chapter 8) that are null\effnull, true\efftrue, false\efffalse, numbers, strings or byte sequences: Eq(v,v′)={True}\dbEq(v,v')=\{\kw{True}\} if vv and v′v' are the same, and {False}\{\kw{False}\} otherwise.

  4. If vv and v′v' have the same form, with components v1,…,vkv_1,\ldots,v_k and v1′,…,vk′v'_1,\ldots,v'_k (k≥0k\geq 0), as listed below, then True∈Eq(v,v′)\kw{True}\in\dbEq(v,v') if True∈Eq(vi,vi′)\kw{True}\in\dbEq(v_i,v'_i) for every ii, and False∈Eq(v,v′)\kw{False}\in\dbEq(v,v') if False∈Eq(vi,vi′)\kw{False}\in\dbEq(v_i,v'_i) for some ii. The forms are:

    • tuples with the same number of components;

    • constructor values con v1⋯vk\con\ v_1\cdots v_k and con v1′⋯vk′\con\ v'_1\cdots v'_k with the same constructor name and k=arity(con)k=\arity(\con);

    • records rr and r′r' with Dom r=Dom r′\Dom r=\Dom r', the components being r(lab)r(\lab) and r′(lab)r'(\lab) for each lab∈Dom r\lab\in\Dom r;

    • arrays of boundary values (JSON arrays among them) with the same number of elements, and objects of boundary values with the same set of keys, the components being the values at each key;

    • effect values (Chapter 8) of the same form, with the same primitives, managers and port names, the components being the values, boundary values, tasks, commands and subscriptions they contain.

  5. Otherwise Eq(v,v′)={False}\dbEq(v,v')=\{\kw{False}\}.

Figure 54: Equality of Values
Read it in its chapter·Permanent address: /standard/figures/dynamic-basis-eq

Referred to from

Tests (1)

  • elm / ArrayEqualityFlagsTest
    Two arrays are equal under `==` when they hold equal elements in the same order: arrays received as flags are compared, with the same elements, a different element, and a different length.

Discussions

Discuss this figure·Search the discussions on GitHub

Discussions are on GitHub; one about this figure has [fig:dynamic-basis-eq] in its title.

A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.