{"id":95,"date":"2025-08-21T15:49:44","date_gmt":"2025-08-21T19:49:44","guid":{"rendered":"https:\/\/www.eventfulstories.info\/?page_id=95"},"modified":"2025-09-01T17:15:27","modified_gmt":"2025-09-01T21:15:27","slug":"data-type-context","status":"publish","type":"page","link":"https:\/\/www.eventfulstories.info\/?page_id=95","title":{"rendered":"Type Context"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">The Purpose of Data Types<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Eventful Stories associates every stored fact with a formally-defined data type without exception. The data types are similar to what many programming languages support internally for their data records and for the relationships between records.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A type context functions like a database schema. Eventful Stories provides a language to define its type systems that makes  it easy to define type contexts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The first section describes the simplifying constraints placed on type context designs to promote intuitive understanding. Domain specialists can easily write their own type systems without being database experts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Two small examples of a type and a type context are presented in the second section, <em>Sample Data Types<\/em>..<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Type Context Design Constraints: What&#8217;s Different<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Three primary constraints are imposed to render type contexts simpler and more attractive for domain specialists, the main user group invited to use Eventful Stories:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Super- and sub-types <\/li>\n\n\n\n<li>Type-naming rules<\/li>\n\n\n\n<li>Field value declarations and sub-types<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Eventful Stories defines a language in which to define type contexts. An example of a full type context definition and a walk-through of its content is given in the technical area of this site. In this general introduction, the three constraints will be briefly covered.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Super- and Sub-types<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Types are defined as a hierarchy in the form of a tree. At the bottom are a set of root types. These categorize trunks of the tree saying what everything that depends on that root &#8220;is&#8221;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Examples of root types are <em>Person<\/em>, <em>Event<\/em>, <em>Time<\/em>, <em>Company<\/em>, <em>Phylum<\/em>, <em>Animal<\/em>, etc. Roots are broad and foundational.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Every <em>Entity<\/em> or data type that is not a root has a super-type. An example is a refinement of the root type <em>Time<\/em> which are more specific expressions of the concept of a time. As chosen by the user, these sub-types of the super-type might be <em>Universal<\/em>, <em>Local<\/em>, <em>Century<\/em>, <em>Ephemeris<\/em>, and so forth.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Universal time or UT is the time at London for any instant. A definition of the specialization of <em>Time<\/em> as universal time looks like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>type Time :&gt; Universal<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The notation &#8220;:&gt;&#8221; means &#8220;is the super-type of&#8221;. This says that a type is being defined which is a sub-type of <em>Time<\/em>. The new sub-type is called <em>Universal<\/em> with the full name <em>Time.Universal<\/em>. The super-type of <strong><em>Time.Universal<\/em><\/strong> is <em>Time<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One can say that <em>TIme.Universal<\/em> &#8220;is-a&#8221; kind of <em>Time<\/em>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Type-naming rules<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Entities are  analogous to data tables in a relational database. Indeed, one option for exporting the content of an Evidence Module is as a normalized relational database with meaningful table names.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In a relational database there is no constraint on the naming of tables beyond that the names must be distinct. That is not enough of a constraint to render names meaningful for a user of a system like Eventful Stories. Rather than <em>Time.Universal<\/em>, its name could be &#8220;zorch_17&#8221; which conveys no meaning. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The type naming rule that aims to communicate more expressively is that every type declaration such as that for <em>Time.Universal <\/em>can supply just a one-word refinement label of its own, such as <em>Universal<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A type or root can have any number of immediate sub-types as long as they&#8217;re distinctly named.  As suggested above, these might be <em>Time.Local<\/em>, <em>Time.Century<\/em>, <em>Time.Ephemeris<\/em>. This is like the constraints placed on directory and file naming in most file systems.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This following example fragment is illegal because there are redundant definitions of <em>Time.Universal<\/em>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>type Time :&gt; Universal\n...\ntype Time :&gt; Universal\n...<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Sub-types can to be extended to any depth:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>type Time.Universal :&gt; Coordinated\n...\ntype Event.Life.Birth :&gt; Person\n...<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">References to an entity or its sub-types<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The super-type and naming rules make it very easy to identify sub-types of an entity since the sub-type must have the name of the super-type  entity as the prefix of its full name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Any type or entity has one or more super types. These are the all the entities on the path towards the root. Since each type has exactly one super-type, and the path ends at root, the set of super-types is well defined and unambiguous.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Attributes are the named record fields containing the values connected to an entity type.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The reason for the super-type structure lies in the attributes or data fields of a type. The set of attributes for an entity is the union of all of its own attributes and all of its super-types.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here, an <em>Event<\/em> is defined to contain two attributes, a <em>when<\/em> and a <em>where<\/em>. All <em>Events<\/em> and all sub-types of <em>Events<\/em> must have these two attributes. This is what makes the super-type structure useful. You know, at a minimum, that every sub-type of <em>Event<\/em> must at least have these two values supplied.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>type Event\n    when :: Time\n    where :: -&gt; Location<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Adding more attributes to the stack of super-type attributes specializes information. Types become more specific at each step down the sub-type tree<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When it comes to assigning values to an attribute calling for a <em>Time<\/em>, any entity value that has <em>Time<\/em> as a super-type fits the slot <em>when<\/em>. An instance of any of the types <em>Time.Universal<\/em>, <em>Time.Local.Baghdad<\/em>, or <em>Time.Century<\/em> may be supplied for a <em>Time<\/em> value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This structure enables searching and reporting functions to be very general since they can rely on finding what is expressed in the type definition. No matter how complex the sub-typing may be, as long as the data is made up of sub-type instances of <em>Event<\/em>, a list of <em>Events<\/em> can always be mapped according to their time and place.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sample Data Types<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">A Date Type<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A common expression for a date in the US is &#8220;YYYY\/MM\/DD&#8221;. The date may be recorded as a set of three integers, with limits to the range of values each may take.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">How this storage is carried out requires a template or a specification to ensure understanding and consistency. Without a specification, for example, there will be ambiguity in the order of the month and day. While Groundhog Day (February 2) or Cinco de Mayo (May 5) aren&#8217;t ambiguous as to month and day ordering, &#8220;2025\/3\/9&#8221; is: it can be understood as either March 9th or September 3rd unless a template or type signature is defined.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The data type context applies this concept to everything, forming a hierarchical structure to impose meaning on every bit of the raw data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Capturing a date as three integers involves  assigning values to a particular record type, or entity. One way to define a date with three integers in Eventful Stories is:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>type Time.Date :&gt; Int\n    &lt;&lt;A date expressed as three Ints&gt;&gt;\n    year :: Int &lt;&lt;The year&gt;&gt;\n    month :: Int &lt;&lt;The month of the year&gt;&gt;\n    day :: Int &lt;&lt;The day of the month&gt;&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This says that there will be a record or entity in the system whose type is <em>Time.Date.Int<\/em>, a record of a date as a set of integer values in a defined order.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">A Minimal Type Context<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The illustration at the top of the page shows the very simple type context used to form type hierarchy for the example of <a href=\"https:\/\/www.eventfulstories.info\/?page_id=168\" data-type=\"page\" data-id=\"168\">Oppenheimer<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are three Entities:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><em>Identity<\/em><\/li>\n\n\n\n<li><em>Event<\/em><\/li>\n\n\n\n<li><em>Association<\/em><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The <em>Identity<\/em> record contains the <em>name<\/em> of someone, something or some place, like &#8220;Albert Einstein&#8221; or &#8220;Cambridge University&#8221;. The <em>type<\/em> field distinguishes between naming a <em>Person<\/em>, <em>Place<\/em>, or any other named item.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <em>Event<\/em> record states that something happened at a certain time and place, and may or may not have had a duration worth noting. The <em>start<\/em> field gives the starting date, <em>end<\/em> gives the ending date, if any, and <em>location<\/em> points to an Identity record giving the locality of the event. What sort of event it was is given by the <em>type<\/em> field.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <em>Association<\/em> record relates an <em>Identity<\/em> with an <em>Event<\/em> in a way indicated by the <em>Association Type<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next: <em><a href=\"https:\/\/www.eventfulstories.info\/?page_id=92\" data-type=\"page\" data-id=\"92\">Provenance<\/a><\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In-depth technical information on the type context definition language:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.eventfulstories.info\/?page_id=372\" data-type=\"page\" data-id=\"372\">Type Context Definition Language<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Purpose of Data Types Eventful Stories associates every stored fact with a formally-defined data type without exception. The data types are similar to what many programming languages support internally for their data records and for the relationships between records. A type context functions like a database schema. Eventful Stories provides a language to define [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":185,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-95","page","type-page","status-publish","has-post-thumbnail","hentry"],"_links":{"self":[{"href":"https:\/\/www.eventfulstories.info\/index.php?rest_route=\/wp\/v2\/pages\/95","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.eventfulstories.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.eventfulstories.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.eventfulstories.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.eventfulstories.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=95"}],"version-history":[{"count":19,"href":"https:\/\/www.eventfulstories.info\/index.php?rest_route=\/wp\/v2\/pages\/95\/revisions"}],"predecessor-version":[{"id":460,"href":"https:\/\/www.eventfulstories.info\/index.php?rest_route=\/wp\/v2\/pages\/95\/revisions\/460"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.eventfulstories.info\/index.php?rest_route=\/wp\/v2\/media\/185"}],"wp:attachment":[{"href":"https:\/\/www.eventfulstories.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}