Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Type System

Every attribute (has) and property range in Dolfin has a type. A type is one of:

  • a primitive (string, int, float, boolean),
  • a temporal type (date, time, date_time, duration),
  • a concept you declared, or
  • a closed concept (one of).

Types are what appears after the : in a has declaration or on either side of a property’s ->:


concept Person:
  has name: one string
  has born: optional date
  has employer: optional Organization

Primitive types

TypeDescriptionXSD datatypeValue examples
stringTextxsd:string"hello", ""
intIntegerxsd:integer0, 42, -7
floatFloating-pointxsd:float3.14, -0.5
booleanBooleanxsd:booleantrue, false

Temporal types

Temporal types carry dates, times, timestamps and durations. Their values are written as smart literals, a type keyword plus human-friendly notation in parentheses (see Temporal values). Dolfin parses the notation and emits the exact XSD lexical form.

TypeXSD datatypeSmart literalEmitted value
datexsd:datedate(June 1st 2026)2026-06-01
timexsd:timetime(2:30 PM UTC)14:30:00+00:00
date_timexsd:dateTimedate_time(June 1st 2026, 14:30)2026-06-01T14:30:00
durationxsd:durationduration(1y 6mo)P1Y6M

Two file-level directives supply defaults used while resolving temporal values:

  • @locale d/m/y: field order for numeric dates without an inline as mask.
  • @timezone <zone>: default timezone for time / date_time values without an inline offset.

See File-level directives. Inline information (an as mask, an inline offset) always overrides the directive.


Concept types

Any concept name is a type. Using it as a range means “an instance of that concept” (or a subtype of it, since sub inheritance is transitive):


concept Animal
concept Dog:
  sub Animal

concept Shelter:
  has residents: some Animal   # Dogs qualify, being Animals

Concept-typed values are references (:id) or inline anonymous blocks ([ ... ]) in facts, see Facts.


Closed concepts (one of)

A closed concept enumerates a fixed set of named members; only those members are valid values:


concept Status:
  one of:
    Pending
    Active
    Archived

concept Ticket:
  has status: one Status

Members are referenced unquoted (Active), not as strings.


Cardinality

Cardinality is orthogonal to type: it constrains how many values of the type an attribute may hold (one, optional, some, N, N..M, …). It is written before the type. See Cardinality for the full table.


has tags: some string          # one or more strings
has born: optional date        # zero or one date
has visits: date_time          # any number of timestamps