Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed list directly into AST type #170

Merged
merged 3 commits into from
Oct 19, 2022
Merged

Embed list directly into AST type #170

merged 3 commits into from
Oct 19, 2022

Conversation

samhh
Copy link
Member

@samhh samhh commented Oct 17, 2022

Rather than our Node constructors containing [Node], they now contain Node in those places, and an additional Node sibling. In a sense this is directly embedding Haskell's singly-linked list into our core AST type, hence the addition of the Fin constructor, equivalent to list Nil. Alternative primed constructors are supplied via patterns, so instead of String x Fin you can write String' x.

With this PR alone it's a relatively neutral change, but it enables more powerful recursion schemes in #171.

Additionally an IsString instance has been added, which can be backported to the previous AST representation if this PR isn't merged. It transforms "xy" directly into Char 'x' (Char 'y' Fin) (previously Plaintext "xy").

Oh, and with us embracing holding chars rather than strings, we can say goodbye to mergePlaintext.

Before (with IsString sugar): ["Hello ", String "name", etc]

After: mconcat ["Hello", String' "name", etc]

samhh added 3 commits October 16, 2022 18:15
This is a neutral change alone, however it opens the door to a better
pattern functor later on.

The `IsString` sugar could be backported to the old AST.
@samhh samhh merged commit 450ed20 into master Oct 19, 2022
@samhh samhh deleted the no-list-ast branch October 19, 2022 11:55
@samhh samhh mentioned this pull request Oct 24, 2022
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