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 of unsafePerformIO #951

Closed
throwaway1037 opened this issue Aug 19, 2022 · 1 comment
Closed

Use of unsafePerformIO #951

throwaway1037 opened this issue Aug 19, 2022 · 1 comment
Labels

Comments

@throwaway1037
Copy link

throwaway1037 commented Aug 19, 2022

https://github.com/jaspervdj/hakyll/blob/master/lib/Hakyll/Main.hs#L202
progName = unsafePerformIO getProgName

Is the use of unsafePerformIO necessary?
Is there a reason this cannot be done safely, or was this a post-hoc addition?

I think refactoring it to be a safe call to getProgName would require modifying the functions which use progName.

@Minoru
Copy link
Collaborator

Minoru commented Aug 23, 2022

Hi! Judging by git log --patch --follow lib/Hakyll/Main.hs, this used to be an implementation detail that became a part of the interface with #755. Now, we can't easily avoid unsafePerformIO because the users of the value don't use the IO monad.

I don't see much harm in this call though. It simply looks at the first element of argv, which is technically not a constant, but practically is.

I'll merge a PR that refactors this, preferably in a way that doesn't change the existing type signatures (so add a new function, deprecate the old one). But I honestly don't think that this is worth an effort, so I'll close this issue now.

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

No branches or pull requests

2 participants