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

Use Managed monad in CLI #42

Open
riz0id opened this issue Feb 3, 2022 · 1 comment
Open

Use Managed monad in CLI #42

riz0id opened this issue Feb 3, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@riz0id
Copy link
Collaborator

riz0id commented Feb 3, 2022

Currently Language.Spectacle.Interaction.Options uses a file Handle to write model checker logs to a file if the user provides an output path with --output/-o and is subsequently closed when CLI is completed in Language.Spectacle.Interaction.CLI.

Manually managing this handle is error-prone. @ixmatus noted using the Managed monad to handle cleanup of file Handles would be an improvement.

@riz0id riz0id added the enhancement New feature or request label Feb 3, 2022
@evanrelf
Copy link
Contributor

evanrelf commented Feb 3, 2022

Some other ideas to consider:

  • Follow the withFile style instead of openFile:

    -handleFrom :: OutputOpt -> IO Handle
    +withHandleFrom :: OutputOpt -> (Handle -> IO a) -> IO a
  • resourcet is similar to managed, but it lets you free resources early (managed holds onto resources until you leave the Managed monad).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants