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

Find a more general replacement for class PrettyPrint from SAWScript.AST #950

Open
brianhuffman opened this issue Dec 4, 2020 · 1 comment
Assignees
Labels
tech debt Issues that document or involve technical debt type: bug Issues reporting bugs or unexpected/unwanted behavior
Milestone

Comments

@brianhuffman
Copy link
Contributor

Module SAWScript.AST (which includes pretty printing functions for the AST datatypes) defines a class PrettyPrint with a function pretty :: Int -> a -> Doc:

class PrettyPrint p where
pretty :: Int -> p -> PP.Doc

As @kquick points out (#931 (comment)), this definition is a bit confusing, considering that other prettyprinting libraries define a very similar class with a similarly-named function that has a different type:

class Pretty a where
  pretty :: a -> Doc

It doesn't appear that class PrettyPrint is used anywhere else in saw-script at the moment. However, a type class for pretty-printing with precedences might be quite useful if it was standardized, given function names that don't conflict with other pretty printing libraries, and maybe put into a separate package so that it could be used across multiple projects.

@brianhuffman brianhuffman added the tech debt Issues that document or involve technical debt label Dec 4, 2020
@brianhuffman
Copy link
Contributor Author

I should point out that cryptol defines the following class in module Cryptol.Utils.PP, which is another implementation of the same idea:

class PP a where
  ppPrec :: Int -> a -> Doc

(This uses a Doc type from the HughesPJ pretty library, however; in order to be widely used across the SAW ecosystem, it would need to use the prettyprinter Doc type.)

@sauclovian-g sauclovian-g added the type: bug Issues reporting bugs or unexpected/unwanted behavior label Oct 30, 2024
@sauclovian-g sauclovian-g self-assigned this Oct 30, 2024
@sauclovian-g sauclovian-g added this to the 2024T3 milestone Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech debt Issues that document or involve technical debt type: bug Issues reporting bugs or unexpected/unwanted behavior
Projects
None yet
Development

No branches or pull requests

2 participants