Skip to content

Move UID-based chunk references to UIDRef-based chunk references (or UnitypedUIDRef ones) #4541

@balacij

Description

@balacij

Consider the following:

data ThisChunk = TC {
    _tcUid :: UID
  , _tcOtherThings :: [UID]
  , ...
}

data SomeADT = Constructor1 UID
             | Constructor2 UID
             | ...

This is a fair representation of how UIDs might appear in in our chunk types (ThisChunk) and our chunk 'atoms' (SomeADT). UIDs are used to create references to other chunks and to indicate the UID of a chunk itself.

With #4476, we diverge: we solidified that UIDs are meant to be carried solely within chunk types (e.g., ThisChunk), indicating that the chunk's UID should be that UID. In other words, it "owns"/is uniquely identified by that UID. However, as in the above, we don't use UIDs like this at the moment.

With #4320, we introduced TypedUIDRef to build type-safe UID references.

-- | 'UID' references that contain information about the type of data the 'UID'
-- refers to, useful for type-safe dereferencing.
newtype TypedUIDRef typ = TypedUIDRef UID

It happens that this is more useful as well to indicate that the carried UID is meant to be a reference to another chunk. We should replace all references to other chunks with either TypedUIDRef or a newtype UIDRef = UIDRef UID for disambiguating between the UID that a chunk is related to and the UIDs that it is related to.

With this information around, we should be able to further propagate the automation #4476 introduced to chunk atoms (e.g., as @Xinlu-Y had to manually do in #4515 and #4514 ).

For anyone attempting this, for example, you can begin with:

-- | For writing 'Sentence's via combining smaller elements.
-- 'Sentence's are made up of some known vocabulary of things:
--
-- * units (their visual representation)
-- * words (via 'String's)
-- * special characters
-- * accented letters
-- * references to specific layout objects
infixr 5 :+:
data Sentence where
-- | Ch looks up the term for a given 'UID' and displays the term with a given 'SentenceStyle' and 'CapitalizationRule'.
-- This allows Sentences to hold plural forms of 'NamedIdea's.
Ch :: SentenceStyle -> TermCapitalization -> UID -> Sentence
-- | A branch of Ch dedicated to SymbolStyle only.
SyCh :: UID -> Sentence

You should be able to search for UID in the codebase to see all other areas that this needs to be propagated as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions