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

Refactor DebugLevel logic to not use Ord #1800

Closed
martijnbastiaan opened this issue May 3, 2021 · 1 comment · Fixed by #1847
Closed

Refactor DebugLevel logic to not use Ord #1800

martijnbastiaan opened this issue May 3, 2021 · 1 comment · Fixed by #1847

Comments

@martijnbastiaan
Copy link
Member

Over time we've added more and more debug levels:

-- | Debug Message Verbosity
data DebugLevel
= DebugNone
-- ^ Don't show debug messages
| DebugSilent
-- ^ Run invariant checks and err if violated (enabled by any debug flag)
| DebugFinal
-- ^ Show completely normalized expressions
| DebugName
-- ^ Show names of applied transformations
| DebugTry
-- ^ Show names of tried AND applied transformations
| DebugApplied
-- ^ Show sub-expressions after a successful rewrite
| DebugAll
-- ^ Show all sub-expressions on which a rewrite is attempted
deriving (Eq,Ord,Read,Enum,Generic,Hashable)

PR #1647 will add yet another one. We're currently using Ord to determine whether an option is enabled (well, most of the time). The number of debug options has outgrown this strategy. For example; enabling a count summary should probably not affect whether the core of a normalized binder is printed.

@martijnbastiaan
Copy link
Member Author

This change has been implemented:


With the old DebugLevel type for setting debug options, it was not possible to set certain debug options without implying others, i.e. counting transformations was not possible without also printing at least the final normalized core for a term. It is now possible to set options individually with new flags:

  • -fclash-debug-invariants to check invariants and print warnings / errors
  • -fclash-debug-info to choose how much information to show about individual transformations
  • -fclash-debug-count-transformations to print a tally of each transformation applied

The old -fclash-debug flag is still available for backwards compatibility, and each DebugLevel is now a synonym for setting these options together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant