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

Pretty-print n => Char tables as string literals. #329

Merged
merged 1 commit into from
Dec 15, 2020

Conversation

dan-zheng
Copy link
Collaborator

Make prettyVal print n => Char tables as string literals.
Add make update-all command for updating all test files. Update tests.

Resolves #321.
Depends on #327, which should be reviewed and merged first.


Examples:

>=> "hello world"
"hello world"

>=> AsList _ "hello " <> AsList _ "world"
(AsList 11 "hello world")

>=> {a="1234", b=[1, 2, 3]}
{a = "1234", b = [1, 2, 3]}

>=> x = "ab"
>=>  for i,j. [x.i, x.j]
["aa", "ab", "ba", "bb"]@(Fin 2 & Fin 2)

@google-cla google-cla bot added the cla: yes label Dec 10, 2020
@dan-zheng dan-zheng force-pushed the print-string-literals branch from 2340983 to 9ddd1f5 Compare December 10, 2020 01:26
src/lib/Serialize.hs Outdated Show resolved Hide resolved
src/lib/Serialize.hs Outdated Show resolved Hide resolved
@apaszke
Copy link
Collaborator

apaszke commented Dec 10, 2020

This needs a rebase now. @dougalm this is going to conflict with your PR. What order should we merge those in?

@dan-zheng dan-zheng force-pushed the print-string-literals branch from 9ddd1f5 to 29c6c80 Compare December 10, 2020 14:06
Make `prettyVal` print `n=>Char` tables as string literals.

Add `make update-all` command for updating all test files.
Update tests.
@dan-zheng dan-zheng force-pushed the print-string-literals branch from 2e25404 to 41c0d5c Compare December 12, 2020 02:52
Copy link
Collaborator Author

@dan-zheng dan-zheng left a comment

Choose a reason for hiding this comment

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

Rebased on dev after #315 was merged. Tests pass again.

return $ pretty elems <> idxSetStr
atom <- evalBlock mempty $ snd $ applyAbs abs idx
case atom of
Con (Lit (Word8Lit c)) ->
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note: #315 removed the pattern CharLit c, so the replacement is now Con (Lit (Word8Lit c)).

Could we add a new abbreviated pattern for this, while being future-facing for potential Unicode support? I wonder what would be a good name.

let bodyType = getType body
let elemsDoc = case bodyType of
-- Print table of characters as a string literal.
TC (BaseType (Scalar Word8Type)) -> pretty ('"': concat elems ++ "\"")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note: #315 removed the pattern CharType, so the replacement is now TC (BaseType (Scalar Word8Type)).

Could we add a new abbreviated pattern for this, while being future-facing for potential Unicode support? I wonder what would be a good name.

@apaszke apaszke merged commit de993f8 into google-research:dev Dec 15, 2020
@apaszke
Copy link
Collaborator

apaszke commented Dec 15, 2020

Thanks, Dan!

@dan-zheng dan-zheng deleted the print-string-literals branch December 15, 2020 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants