Skip to content

Conversation

Soupstraw
Copy link
Collaborator

@Soupstraw Soupstraw commented Oct 2, 2025

This PR changes the representation of the CTree AST to trees that grow. This is a step towards having a single AST representation across the entire repo.

I got rid of the fixpoint decorations by adding a CTreeE constructor to the CTree datatype, which can be used to store each of the different references by choosing the right index type. This approach of with the index can also be later used to add additional fields to the terms (e.g. for storing custom generators or comments for each term).

@Soupstraw Soupstraw force-pushed the jj/unify-asts branch 2 times, most recently from 20f577c to 8c2caac Compare October 2, 2025 11:15
@Soupstraw Soupstraw changed the title Change the AST representation of CTree to use "Trees that grow" Change the AST representation of CTree to use "Trees that grow" Oct 2, 2025
@Soupstraw Soupstraw requested review from jasagredo and nc6 and removed request for jasagredo October 2, 2025 12:28
@Soupstraw Soupstraw marked this pull request as ready for review October 2, 2025 12:29
@Soupstraw Soupstraw mentioned this pull request Oct 8, 2025
Copy link
Member

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

type instance CTreeExt OrReferenced = OrRef (CTree OrReferenced)

-- | Indicates that an item may be referenced rather than defined.
data OrRef a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this type parameter still needed?

Suggested change
data OrRef a
data OrRef

deriving (Show)

deriving instance Eq (OrRef (CTree OrRef)) => Eq NameResolutionFailure
deriving instance Eq (CTree.Node OrReferenced) => Eq NameResolutionFailure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constraint should not be necessary. It is fully saturated and Eq for Node is not an orphan instance

Suggested change
deriving instance Eq (CTree.Node OrReferenced) => Eq NameResolutionFailure
deriving instance Eq NameResolutionFailure


data OrReferenced

type instance CTreeExt OrReferenced = OrRef (CTree OrReferenced)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment below

Suggested change
type instance CTreeExt OrReferenced = OrRef (CTree OrReferenced)
type instance CTreeExt OrReferenced = OrRef

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants