<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">Ah, so returning to my original question:</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_default" style="font-family:tahoma,sans-serif">Where is this described/documented? All I can see <a href="https://github.com/ndmitchell/hlint#readme" target="_blank">here </a>is...</div></blockquote><div><br></div><div>E.g. is there a HLint user guide? I'm interested in what the annotations can and cannot be. E.g. perhaps ANN could shortcircuit the TH stuff in some common cases?</div><div><br></div><div>Simon<br></div><div><br></div><div> <br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 4 Dec 2023 at 12:15, Moritz Angermann <<a href="mailto:moritz.angermann@gmail.com">moritz.angermann@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">I see. That’s where the confusion comes from. Hlint uses them to allow ignoring specific Hlint warnings:</div><div dir="auto"><br></div><div dir="auto"><div><pre style="margin-top:0px;margin-right:0px;margin-left:0px;border:0px;font-style:normal;font-variant-caps:normal;font-weight:400;font-stretch:inherit;font-size-adjust:inherit;font-kerning:inherit;font-variant-alternates:inherit;font-variant-ligatures:inherit;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;word-spacing:0px;text-decoration:none;color:rgb(12,13,14)" dir="auto"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant-caps:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-size-adjust:inherit;font-kerning:inherit;font-variant-alternates:inherit;font-variant-ligatures:inherit;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;white-space:inherit;background-color:transparent"><span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant-caps:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-size-adjust:inherit;font-kerning:inherit;font-variant-alternates:inherit;font-variant-ligatures:inherit;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">{-# ANN module "HLint: ignore Use string literal" #-}</span></code></pre><pre style="margin-top:0px;margin-right:0px;margin-left:0px;border:0px;font-style:normal;font-variant-caps:normal;font-weight:400;font-stretch:inherit;font-size-adjust:inherit;font-kerning:inherit;font-variant-alternates:inherit;font-variant-ligatures:inherit;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;word-spacing:0px;text-decoration:none;color:rgb(12,13,14)" dir="auto"><span style="font-size:13px;font-style:inherit;font-variant-caps:inherit;white-space:inherit;border-color:currentcolor">{- HLINT ignore "Use string literal" -}</span></pre></div></div><div dir="auto">and similar. One could maybe argue they should have never been ANN pragmas to begin with.</div><div dir="auto"><br></div><div dir="auto">Examples taken from this SO question: <div><a href="https://stackoverflow.com/questions/19237695/haskell-how-to-tell-hlint-not-to-warning-use-string-literal" target="_blank">https://stackoverflow.com/questions/19237695/haskell-how-to-tell-hlint-not-to-warning-use-string-literal</a></div></div><div dir="auto"><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Mon, 4 Dec 2023 at 8:07 PM, Simon Peyton Jones <<a href="mailto:simon.peytonjones@gmail.com" target="_blank">simon.peytonjones@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">>
I don’t think they do anything specific. <br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Now I am truly baffled! If they don't do anything, why would they be a module at all! Surely they do something?</div></div><div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Simon<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 4 Dec 2023 at 11:58, Moritz Angermann <<a href="mailto:moritz.angermann@gmail.com" target="_blank">moritz.angermann@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">I don’t think they do anything specific. They just function as a marker to Hlint to find when parsing the source files. Here is one of the original issues we had: <div><a href="https://github.com/ndmitchell/hlint/issues/1251" target="_blank">https://github.com/ndmitchell/hlint/issues/1251</a></div><div dir="auto"><br></div><div dir="auto">Simply by not being ANN, it doesn’t trigger the Templar Haskell machinery and thus does not cause compilation slowdowns or iserv needs (e.g. render the module impossible to cross compiler for stage1 cross compilers with not TH support).</div></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 4 Dec 2023 at 7:45 PM, Simon Peyton Jones <<a href="mailto:simon.peytonjones@gmail.com" target="_blank">simon.peytonjones@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;font-family:tahoma,sans-serif"><div dir="auto" style="font-family:tahoma,sans-serif">Luckily Hlint also support HLINT instead which removed the TH pipeline.</div></blockquote>
</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Where is this described/documented? All I can see <a href="https://github.com/ndmitchell/hlint#readme" style="font-family:tahoma,sans-serif" target="_blank">here </a>is</div><div class="gmail_default" style="font-family:tahoma,sans-serif">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;font-family:tahoma,sans-serif"><p dir="auto" style="font-family:tahoma,sans-serif">For <code style="font-family:monospace">{-# HLINT #-}</code> pragmas GHC may give a warning about an unrecognised pragma, which can be suppressed with <code style="font-family:monospace">-Wno-unrecognised-pragmas</code>.</p></blockquote><div style="font-family:tahoma,sans-serif">which mentions HLINT pragmas but says nothing about what they do.</div></div></div><div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif"><div style="font-family:tahoma,sans-serif"><br></div><div style="font-family:tahoma,sans-serif">Simon <br></div>
</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 4 Dec 2023 at 09:05, Moritz Angermann <<a href="mailto:moritz.angermann@gmail.com" target="_blank">moritz.angermann@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Any ANN annotation triggers the TH pipeline and makes them really painful to work with, in non-stage2 settings. Lots of Hlint annotations use ANN and then you have iserv be triggered for each module that has an ANN annotation.</div><div dir="auto"><br></div><div dir="auto">Luckily Hlint also support HLINT instead which removed the TH pipeline.</div><div dir="auto"><br></div><div dir="auto">That alone is enough for me personally to recommend against using ANN if there is an alternator option to anyone who asks me.</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 4 Dec 2023 at 5:01 PM, Simon Peyton Jones <<a href="mailto:simon.peytonjones@gmail.com" target="_blank">simon.peytonjones@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">The whole <a href="https://ghc.gitlab.haskell.org/ghc/doc/users_guide/extending_ghc.html?highlight=ann#source-annotations" style="font-family:tahoma,sans-serif" target="_blank">ANN mechanism </a>is, at root, a good idea. It is pretty generan, and allows annotations to be arbitrary expressions, provided they are in Typable and Data. And they are serialised across modules.</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">In practice though, I'm not sure how widely used they are. I'm not sure why. I'd love to hear of counter-examples.</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Only top level binders can be annotated; but there is no reason in principle that you should not annotate instance declarations. I don't think it'd be too hard to implement.</div></div><div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Simon<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 2 Dec 2023 at 14:51, Jaro Reinders <<a href="mailto:jaro.reinders@gmail.com" target="_blank">jaro.reinders@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi GHC devs,<br>
<br>
I'm working on a GHC plugin which implements a custom instance resolution <br>
mechanism:<br>
<br>
<a href="https://github.com/noughtmare/transitive-constraint-plugin" rel="noreferrer" target="_blank">https://github.com/noughtmare/transitive-constraint-plugin</a><br>
<br>
Currently, I need to place instances in a specific order in a specific file to <br>
recognize them and use them in my plugin. I think my life would be a lot easier <br>
if I could put annotations on instances. I imagine a syntax like this:<br>
<br>
data MyInstanceTypes = Refl | Trans deriving Eq<br>
<br>
class f <= g where<br>
inj :: f x -> g x<br>
<br>
instance {-# ANN instance Refl #-} f <= f where<br>
inj = id<br>
<br>
instance {-# ANN instance Trans #-}<br>
forall f g h. (f <= g, g <= h) => f <= h<br>
where<br>
inj = inj @g @h . inj @f @g<br>
<br>
Using this information I should be able to find the right instances in a more <br>
reliable way.<br>
<br>
One more thing I was thinking about is to make it possible to remove these <br>
instances from the normal resolution algorithm and only allow them to be used <br>
by my plugin.<br>
<br>
Do you think this would be easy to implement and useful? Or are there other <br>
ways to achieve this?<br>
<br>
Cheers,<br>
<br>
Jaro<br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div></div>
</blockquote></div>
</blockquote></div></div>
</blockquote></div>
</blockquote></div></div>
</blockquote></div>