elipl/lib/tilly/type.ex
Kacper Marzecki 748f87636a checkpoint
checkpoint

failing test

after fixing tests

checkpoint

checkpoint

checkpoint

re-work

asd

checkpoint

checkpoint

checkpoint

mix proj

checkpoint mix

first parser impl

checkpoint

fix tests

re-org parser

checkpoint strings

fix multiline strings

tuples

checkpoint maps

checkpoint

checkpoint

checkpoint

checkpoint

fix weird eof expression parse error

checkpoint before typing

checkpoint

checpoint

checkpoint

checkpoint

checkpoint ids in primitive types

checkpoint

checkpoint

fix tests

initial annotation

checkpoint

checkpoint

checkpoint

union subtyping

conventions

refactor - split typer

typing tuples

checkpoint test refactor

checkpoint test refactor

parsing atoms

checkpoint atoms

wip lists

checkpoint typing lists

checkopint

checkpoint

wip fixing

correct list typing

map discussion

checkpoint map basic typing

fix tests checkpoint

checkpoint

checkpoint

checkpoint

fix condition typing

fix literal keys in map types

checkpoint union types

checkpoint union type

checkpoint row types discussion & bidirectional typecheck

checkpoint

basic lambdas

checkpoint lambdas typing application

wip function application

checkpoint

checkpoint

checkpoint cduce

checkpoint

checkpoint

checkpoint

checkpoint

checkpoint

checkpoint

checkpoint
2025-06-13 23:48:07 +02:00

58 lines
1.9 KiB
Elixir

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