defmodule Tilly.Type do @moduledoc """ Defines the structure of a Type Descriptor (`Descr`) and provides helper functions for creating fundamental type descriptors. A Type Descriptor is a map representing a type. Each field in the map corresponds to a basic kind of type component (e.g., atoms, integers, pairs) and holds a BDD node ID. These BDDs represent the set of values allowed for that particular component of the type. """ alias Tilly.BDD @doc """ Returns a `Descr` map representing the empty type (Nothing). All BDD IDs in this `Descr` point to the canonical `false` BDD node. The `typing_ctx` is passed for consistency but not modified by this function. """ def empty_descr(_typing_ctx) do false_id = BDD.false_node_id() %{ atoms_bdd_id: false_id, integers_bdd_id: false_id, strings_bdd_id: false_id, pairs_bdd_id: false_id, records_bdd_id: false_id, functions_bdd_id: false_id, absent_marker_bdd_id: false_id # Add other kinds as needed, e.g., for abstract types } end @doc """ Returns a `Descr` map representing the universal type (Any). All BDD IDs in this `Descr` point to the canonical `true` BDD node. The `typing_ctx` is passed for consistency but not modified by this function. """ def any_descr(_typing_ctx) do true_id = BDD.true_node_id() %{ atoms_bdd_id: true_id, integers_bdd_id: true_id, strings_bdd_id: true_id, pairs_bdd_id: true_id, records_bdd_id: true_id, functions_bdd_id: true_id, # For 'Any', absence is typically not included unless explicitly modeled. # If 'Any' should include the possibility of absence, this would be true_id. # For now, let's assume 'Any' means any *value*, so absence is false. # This can be refined based on the desired semantics of 'Any'. # CDuce 'Any' does not include 'Absent'. absent_marker_bdd_id: BDD.false_node_id() } end end