<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="static/style.xsl"?><OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd"><responseDate>2026-11-23T02:23:58Z</responseDate><request verb="GetRecord" identifier="oai:uwspace.uwaterloo.ca:10012/21428" metadataPrefix="dim">https://dspacemainprd01.lib.uwaterloo.ca/server/oai/request</request><GetRecord><record><header><identifier>oai:uwspace.uwaterloo.ca:10012/21428</identifier><datestamp>2025-03-26T23:32:27Z</datestamp><setSpec>com_10012_9924</setSpec><setSpec>com_10012_1</setSpec><setSpec>col_10012_9930</setSpec><setSpec>col_10012_6</setSpec></header><metadata><dim:dim xmlns:dim="http://www.dspace.org/xmlns/dspace/dim" xmlns:doc="http://www.lyncode.com/xoai" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dspace.org/xmlns/dspace/dim http://www.dspace.org/schema/dim.xsd">
   <dim:field mdschema="dc" element="contributor" qualifier="advisor">Lhoták, Ondřej</dim:field>
   <dim:field mdschema="dc" element="contributor" qualifier="author">Magnan Cavalcante Oliveira, Pedro Jorge</dim:field>
   <dim:field mdschema="dc" element="date" qualifier="accessioned">2025-01-23T19:23:14Z</dim:field>
   <dim:field mdschema="dc" element="date" qualifier="available">2025-01-23T19:23:14Z</dim:field>
   <dim:field mdschema="dc" element="date" qualifier="issued">2025-01-23</dim:field>
   <dim:field mdschema="dc" element="date" qualifier="submitted">2025-01-14</dim:field>
   <dim:field mdschema="dc" element="identifier" qualifier="uri">https://hdl.handle.net/10012/21428</dim:field>
   <dim:field mdschema="dc" element="description" qualifier="abstract">Compilers translate programs from a source language to a target language. This can be
done by translating into an intermediate tree representation, performing multiple partial
transformations on the tree, and translating out. Compiler implementers must choose
between encoding transformation invariants with multiple tree types at the cost of code
boilerplate and duplication, or forgoing static correctness by using a broad and imprecise
tree datatype.
This thesis proposes a new approach to writing precisely-typed compilers and tree
transformations without code boilerplate or duplication. The approach requires encoding
the tree nodes using two type indices, one for the phase of the root node and another for
the phase of all children nodes. This tree datatype can represent partially transformed
nodes, and distinguish between trees of different phases.
In order to make this approach possible it was necessary to modify the Scala type
checker to better infer types in ‘match’-expressions. Precisely-typed tree transformations
make use of the default case of a ‘match’-expression; this case must be elaborated to a
type which is the type difference of the scrutinee expression and all previously matched
patterns.
We demonstrate the viability of this approach by implementing a case study for a
precisely-typed compiler for the instructional language Lacs. This case study modifies the
existing implementation of Lacs to track which subset of tree nodes may be present before
and after any given tree transformation. We show that this approach can increase static
correctness without the burden of additional code boilerplate or duplication.</dim:field>
   <dim:field mdschema="dc" element="language" qualifier="iso">en</dim:field>
   <dim:field mdschema="dc" element="publisher" lang="en">University of Waterloo</dim:field>
   <dim:field mdschema="dc" element="subject">programming languages</dim:field>
   <dim:field mdschema="dc" element="subject">compilers</dim:field>
   <dim:field mdschema="dc" element="subject">type theory</dim:field>
   <dim:field mdschema="dc" element="title">Type-Safe Tree Transformations for Precisely-Typed Compilers</dim:field>
   <dim:field mdschema="dc" element="type">Master Thesis</dim:field>
   <dim:field mdschema="dc" element="pending">false</dim:field>
   <dim:field mdschema="uws-etd" element="degree" qualifier="department">David R. Cheriton School of Computer Science</dim:field>
   <dim:field mdschema="uws-etd" element="degree" qualifier="discipline">Computer Science</dim:field>
   <dim:field mdschema="uws-etd" element="degree" qualifier="grantor" lang="en">University of Waterloo</dim:field>
   <dim:field mdschema="uws-etd" element="degree">Master of Mathematics</dim:field>
   <dim:field mdschema="uws-etd" element="embargo" qualifier="terms">0</dim:field>
   <dim:field mdschema="uws" element="contributor" qualifier="advisor">Lhoták, Ondřej</dim:field>
   <dim:field mdschema="uws" element="contributor" qualifier="affiliation1">Faculty of Mathematics</dim:field>
   <dim:field mdschema="uws" element="published" qualifier="city" lang="en">Waterloo</dim:field>
   <dim:field mdschema="uws" element="published" qualifier="country" lang="en">Canada</dim:field>
   <dim:field mdschema="uws" element="published" qualifier="province" lang="en">Ontario</dim:field>
   <dim:field mdschema="uws" element="typeOfResource" lang="en">Text</dim:field>
   <dim:field mdschema="uws" element="peerReviewStatus" lang="en">Unreviewed</dim:field>
   <dim:field mdschema="uws" element="scholarLevel" lang="en">Graduate</dim:field>
   <dim:field mdschema="others" element="access-status">open.access</dim:field>
</dim:dim>
</metadata></record></GetRecord></OAI-PMH>