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

Fix Cassius, Lucius reload mode #207

Merged
merged 2 commits into from Aug 8, 2017
Merged

Conversation

alx741
Copy link
Contributor

@alx741 alx741 commented Aug 7, 2017

@psibi
Copy link
Member

psibi commented Aug 7, 2017

@alx741 Are you sure this is a right fix ? I think you should just remove the directives and qAddDependentFile should be present.

@alx741
Copy link
Contributor Author

alx741 commented Aug 7, 2017

@psibi well, cassiusFile does have qAddDependentFile: https://github.com/yesodweb/shakespeare/blob/master/Text/Cassius.hs#L57-L63 , this is spected as it is the non-reloading one, but cassiusFileReload and luciusFileReload both use cssFileDebug: https://github.com/yesodweb/shakespeare/blob/master/Text/Internal/Css.hs#L172 , which is not supposed to add de files as compilation dependencies.

Is there perhaps a reason to keep qAddDependentFile that I'm not seeing?

Edit: According to my reasoning removing the directives wouldn't do much, as GHC is going to be >= 7.4 in most cases, plus I think the reason for that restriction is that addDepedentFile is only supported since GHC 7.4

@psibi
Copy link
Member

psibi commented Aug 7, 2017

Why do you think cassiusFileReload and luciusFileReload aren't supposed to add files as compilation dependencies ?

Only if you add files as compilation dependencies, they will get re-compiled IIRC.

@alx741
Copy link
Contributor Author

alx741 commented Aug 7, 2017

Whenever addDepedentFile is used, the file that uses the dependent file is marked for recompilation. For instance, in the case of Yesod, cassiusFile and luciusFile require it, as any change in the corresponding template file should mark the invoking handler for recompilation; But when the reload versions are used it shouldn't make the handler recompile (that's the reason of existence of the reload versions) and, because they are read at runtime, they don't need to force recompilation of the handler. One can actually see this happening when observing the effects of the changes in the template files right before the recompiltion begins, as described here: yesodweb/yesod#1425

This way changes in template files mark the invoking Haskell file for recompilation when the normal versions are used, but doesn't when the reload versions are used. Notice how this is the behavior for Julius on the reload version: https://github.com/yesodweb/shakespeare/blob/master/Text/Julius.hs#L197 (no addDependentFile there), whereas the normal version uses shakespeareFile which, in turn, does make use of addDependentFile: https://github.com/yesodweb/shakespeare/blob/master/Text/Shakespeare.hs#L396

@snoyberg
Copy link
Member

snoyberg commented Aug 7, 2017

@psibi This was coming from my recommendation. The behavior we want is that, with yesod devel, runtime loaded files do not trigger recompilation, which is currently not the behavior (at least on @alx741's system, for some reason the behavior on my system is different).

@alx741
Copy link
Contributor Author

alx741 commented Aug 7, 2017

@snoyberg that's the part that intrigues me though, as far as i understand it, it should be reproducible as long as that GHC_7_4 flag is set

@snoyberg
Copy link
Member

snoyberg commented Aug 7, 2017

I checked in my .hi files, I also have the lucius/cassius files listed. I don't know why on my system Stack isn't rebuilding for them. Maybe it's a bug in the devel version of Stack. In any event, the .hi files are authoritative here.

@alx741
Copy link
Contributor Author

alx741 commented Aug 7, 2017

On the other hand... those 3 lines seem to be there for about 5 years now. Either my reasoning about them is incorrect, or there is something weird going on somewhere else.

@snoyberg
Copy link
Member

snoyberg commented Aug 7, 2017

@psibi Do you have any objections to removing this?

@alx741 Can you add a note to the changelog and a minor version bump in the cabal file to explain why the change is happening?

@psibi
Copy link
Member

psibi commented Aug 7, 2017

LGTM. @alx741 Does removing this line actually fixes the problem for you ?

@alx741
Copy link
Contributor Author

alx741 commented Aug 7, 2017

@psibi oh yeah! it did. I tried with a standalone executable that loads a cassius file (with reload mode), and both in an existing Yesod project and a freshly scaffolded one. The needless recompilation is gone in all of them :)

@snoyberg snoyberg merged commit 65834c5 into yesodweb:master Aug 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants