Module

Rebus.Deck

Package
purescript-rebus
Repository
afcondon/purescript-rebus

Rebus.Deck — the icon deck and the colour palette: the two tables a rebus is drawn from.

The deck is a value, not a constant, because some consumer will one day want a deck of its own — animals only, a house icon set, a deck sized to what a small display can render. But read the warning on defaultDeck before reaching for one: swapping decks is a versioning decision, not a preference.

#Deck Source

newtype Deck

An ordered list of icon NAMES. Rebus never draws anything; a name is whatever the consumer's renderer can look up — a FontAwesome class, an SVG id, a key into a sprite sheet.

The deck must hold at least as many entries as the widest rebus drawn from it, since a run is bumped apart so no icon repeats. Size is the whole of the collision story: 64 entries give 64 identities at width one, 64x63 = 4032 at two and 249984 at three, so how wide a consumer draws follows from how many things it must tell apart (see Rebus.Width).

Constructors

Instances

#defaultDeck Source

defaultDeck :: Deck

The deck Rebus ships with: sixty-four concrete, drawable nouns, each of which happens to be a FontAwesome free-solid name so the common case needs no mapping table at all.

ORDER IS THE IDENTITY. An index into this array is what a content hash actually produces, so reordering an entry, removing one, or inserting in the middle silently re-identifies every rebus ever minted: the alias someone wrote down stops matching the picture they remember. The array is therefore FIXED and APPEND-ONLY — and even appending changes identities, because the hash is reduced modulo the deck size.

The same goes for rebusOfWith and a deck of your own. A different deck is a different identity space; two programs that must agree have to agree on the deck first, and a program that changes its deck has performed a data migration whether or not it migrated anything.

#deckSize Source

#without Source

without :: Array String -> Deck -> Deck

The deck with the named icons WITHDRAWN, the rest left in their order.

This is for icons that mean something to your subject. A reader reads a flame as heat and a skull as danger whether or not anyone meant it, so a pure hash will sooner or later say something false: a flame on the thing that is cold. Withdraw every icon that carries meaning for the subject, deal names from what is left, and place the withdrawn ones only by declaration (Rebus.Choice).

The library ships no list of "loaded" icons, on purpose: what is loaded depends on the subject (a bolt means nothing in a build and electricity in a house), so the list belongs with the subject's vocabulary.

The warning on defaultDeck applies with full force. A restricted deck is a different identity space: the same text deals to a different glyph, and an icon withdrawn LATER re-deals everything dealt before. Decide what is withdrawn once, per identity space.

#only Source

only :: Array String -> Deck -> Deck

The deck with ONLY the named icons kept, in the deck's order (not the order they are named in, so two callers who list the same icons differently still hold the same deck). A name the deck does not hold adds nothing.

#Theme Source

data Theme

A named part of defaultDeck. The six themes PARTITION it: every one of the sixty-four icons is in exactly one theme.

A theme is how a picture can say which subject it belongs to before any word is read: deal one subject's names from Animals and another's from Travel and the two cannot share an icon, so they look like two families rather than one. (Rebus.Assign.assignThemes hands themes out to subjects.)

They are unequal in size, and the size is the limit on what a theme can name without two things sharing an icon: Nature 14, Animals 13, Travel and Emblems 12, Tools 9, Music 4. Join themes with themesDeck when one is too small.

A closed set, like Width: the themes are a fact about defaultDeck, not a vocabulary a caller extends. A subset of your own is only.

Constructors

Instances

#allThemes Source

allThemes :: Array Theme

Every theme, in a fixed order.

#themeName Source

themeName :: Theme -> String

A theme's name as text, for a label or a stored setting.

#themeFromName Source

themeFromName :: String -> Maybe Theme

The theme a stored name spells, if it spells one.

#themeIcons Source

themeIcons :: Theme -> Array String

The icons of a theme. Membership is the fact; the order a theme's deck deals in is always defaultDeck's (see themeDeck).

#themeOfIcon Source

themeOfIcon :: String -> Maybe Theme

Which theme an icon of defaultDeck belongs to; Nothing for a name that is not in the default deck.

#themeDeck Source

themeDeck :: Theme -> Deck

The deck of one theme: its icons, in defaultDeck's order.

A different deck, so a different identity space, like any other.

#themesDeck Source

themesDeck :: Array Theme -> Deck

The deck of several themes together, in defaultDeck's order whatever order the themes are named in. themesDeck allThemes == defaultDeck.

#Palette Source

newtype Palette

An ordered list of colours, as whatever string the consumer's renderer understands. The shipped palette is CSS, since that is where these were first drawn, but nothing here parses them.

Constructors

Instances

#defaultPalette Source

defaultPalette :: Palette

Eight hues spaced around the wheel, all mid-dark so a small icon still reads against a light ground.

Unlike the deck, the palette is NOT part of the identity: a rebus is identified by its icons, which is what the alias records, and colour is a memorability accent laid on top ("red cow, blue star" is easier to hold than "cow, star"). Recolouring is therefore a visual change and not a migration — which is why rebusOfWith takes a deck and no palette.

Eight is also why colour de-duplication is only ever pairwise. A run of five icons cannot be given five well-separated hues out of eight, and should not try: all that is needed is that two icons standing side by side are not mistaken for one shape drawn twice.

#paletteSize Source