You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey Matthew, I think if you can answer the questions after this example program, you will be ready to fix the last part of your optimize-par transformation pass.
type Pair2 a b
Pair2 a b
type Pair3 a b c
Pair3 a b c
type Bool
False
True
giveBool x = False
giveNum y = 2
p q = par giveNum 5
giveNum 7
giveBool 5
t r = Pair3 (giveNum 5) (giveNum 7) (giveBool 5)
t2 r2 = Pair3 2 2 False
main cin cout = ()
What is the type of the return value of function p?
Hint: stack exec sslc -- --dump-ir-typed tests/test-file-name.ssl
What is the type of the return value of function t? Of function t2?
Hint: stack exec sslc -- --dump-ir-typed tests/test-file-name.ssl
What is the return value of function t? Of function t2?
Hint: stack exec sslc -- --dump-ir-typed tests/test-file-name.ssl
What does the return value of function t2 look like in the IR? (Draw the IR tree)
Hint1: stack exec sslc -- --dump-ir-typed-ugly tests/test-file-name.ssl
Hint2: It's a bunch of nested application nodes
Hint3: Drawings of the IR tree from this guide might help.
Hint4: Here's how I would add spaces to the dumped IR to make it more readable for function t2:
What is the type of each node in this tree?
Hint: Think partial application of data constructors.
When you transform a par expression into a tuple, the type of the tuple IR node and all of its subnodes must have the correct type. When you pass foldApp a data constructor and a list of arguments, it will wrap them up in the correct nested application form, but foldApp also needs you tell it the type of each node (and subnode) in the nested application in order to perform this wrapping. Suppose you want to construct a tuple that looks like (Pair3 2 2 False); what are the extra types you must provide to foldApp?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
par optimization for par expression with instantaneous arguments