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

Sequences of ASCII values render differently in book and REPL #747

Open
bboston7 opened this issue Jun 2, 2020 · 7 comments
Open

Sequences of ASCII values render differently in book and REPL #747

bboston7 opened this issue Jun 2, 2020 · 7 comments
Labels
book The "Programming in Cryptol" book design needed We need to specify precisely what we want docs LaTeX, markdown, literate haskell, or in-REPL documentation UX Issues related to the user experience (e.g., improved error messages)

Comments

@bboston7
Copy link
Contributor

bboston7 commented Jun 2, 2020

Section 1.8 presents the following example (compressed a bit here to show just the relevant portion):

Cryptol> :set base=10
Cryptol> :set ascii=on
Cryptol> ['A' .. 'Z']
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"

However, in the REPL:

Cryptol> :set base=10
Cryptol> :set ascii=on
Cryptol> ['A'..'Z']
Showing a specific instance of polymorphic result:
  * Using 'Integer' for type argument 'a' of 'Cryptol::fromTo'
[65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
 81, 82, 83, 84, 85, 86, 87, 88, 89, 90]

It appears that :set ascii=on doesn't change the behavior of the pretty printer on sequences of ASCII values. It does, however, work as expected on single characters.

@weaversa
Copy link
Collaborator

weaversa commented Jun 2, 2020

This is happening because the defaulter is assigning the characters values the type of Integer.

Providing a bitvector type such as ['A'..'Z'] : [26][8] solves the problem. The manual should be updated accordingly. You know, there might be a few more of these defaulting issues in the manual.

@robdockins
Copy link
Contributor

Oh, interesting. That enumeration defaulted to a sequence of Integer instead of [8], which I think it used to do. If you instead

Cryptol> ['A'..'Z':[8]]
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"

I think this is yet more evidence that we need to rethink defaulting.

@yav
Copy link
Member

yav commented Jun 2, 2020

This is an interesting interaction indeed. Notice that A and Z are types there, so it's actually even more confusing (the type signature would have to be on the outside)

@yav
Copy link
Member

yav commented Jun 2, 2020

Actually, I guess we added a special case, so the inner signature also works :-) Sigh.

@brianhuffman
Copy link
Contributor

The [a..b:[n]] syntax (with the type annotation inside) was added by #628 to address #625. In a comment there (#625 (comment)) I suggested that using character literals for enumeration bounds should constrain the element type to [8]. Due to lack of response, I left that feature out of the PR; but maybe we should go back and add it to address this ticket?

@yav
Copy link
Member

yav commented Jun 2, 2020

Yeah, the character notation is only really there for the book, so I guess we could make it more user friendly, although it really is promoting a view of how things work, which is not quite right..

I wonder, if it might not be better to simply remove characters literals from the types, as we've discussed before.

@robdockins robdockins added docs LaTeX, markdown, literate haskell, or in-REPL documentation UX Issues related to the user experience (e.g., improved error messages) labels Jun 5, 2020
@robdockins robdockins added the design needed We need to specify precisely what we want label Mar 26, 2021
@robdockins
Copy link
Contributor

CF #864

@RyanGlScott RyanGlScott added the book The "Programming in Cryptol" book label Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
book The "Programming in Cryptol" book design needed We need to specify precisely what we want docs LaTeX, markdown, literate haskell, or in-REPL documentation UX Issues related to the user experience (e.g., improved error messages)
Projects
None yet
Development

No branches or pull requests

6 participants