(home)

🏗️
Hyperstring


What is this

A data type for plain text with links. As hypertext is to rich text, hyperstrings are to strings.

You can implement it in any language. Here's an example in Haskell:

newtype Hyperstring link = [Element]

data Element
  = ElementString String
  | ElementLink String

Is it novel?

Almost certainly not, please point me to prior art if you know of it.

Motivation

I don't like plain text very much, but billions of lines of plain text with implicit links already exist in the form of source code.

As the "don't stucture code as text" movement heats up I wanted a name for plain text with explicit links. It offers an interesting level of disruption/payoff compared to fully structured code, but I don't think it's getting enough consideration.

Invariants

ElementString must not be an empty string. The Hyperstring list must not contain two ElementStrings in a row.

JSON representation

Hyperstring

Encodes as a JSON Array.

Element

Encodes as a JSON Object with a single key/value pair, string for strings and link for links.

Wikilinks representation

Hyperstring

A plain text document.

Element

Unadorned plain text for strings, double-bracket links for links.

Example

A plain text document:

(define (increment n) (+ n 1))

One way to represent this as hypertext (using the Haskell type from earlier):

[ ElementString "(define (increment n) ("
, ElementLink "+"
, ElementString " n 1))"
]

The equivalent Wikilinks representation:

(define (increment n) ([[+]] n 1))

The equivalent JSON:

[ {"string": "(define (increment n) ("}
, {"link": "+"}
, {"string": " n 1))"}
]

Backlinks