<div dir="ltr"><div>I know there was a bug in the parser related to setting the HsBang value, it could be that this whole area has just not received solid scrutiny before now.<br><br></div>Alan<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 8, 2015 at 10:15 AM, Johan Tibell <span dir="ltr"><<a href="mailto:johan.tibell@gmail.com" target="_blank">johan.tibell@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I also note that the definition of isBanged is confusing:<span class=""><div><br></div><div><div style="font-size:13px">  Â  isBanged :: HsBang -> Bool</div><div style="font-size:13px">  Â  isBanged HsNoBang Â  Â  Â  Â  Â  Â  Â  Â  Â = False</div><div style="font-size:13px">  Â  isBanged (HsUserBang Nothing bang) = bang</div><div style="font-size:13px">  Â  isBanged _ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  = True</div></div><div style="font-size:13px"><br></div></span><div style="font-size:13px">Why is `HsUserBang (Just False) False`, corresponding to a NOUNPACK annotations with a missing "!", considered "banged"?</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 8, 2015 at 8:36 AM, Johan Tibell <span dir="ltr"><<a href="mailto:johan.tibell@gmail.com" target="_blank">johan.tibell@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">HsBang is defined as:<br><br><div>  Â  -- HsBang describes what the *programmer* wrote</div><div>  Â  -- This info is retained in the DataCon.dcStrictMarks field</div><div>  Â  data HsBang</div><div>  Â  Â  = HsUserBang Â  -- The user's source-code request</div><div>  Â  Â  Â  Â  Â (Maybe Bool) Â  Â  Â  -- Just True Â  Â {-# UNPACK #-}</div><div>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  -- Just False Â  {-# NOUNPACK #-}</div><div>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  -- Nothing Â  Â  Â no pragma</div><div>  Â  Â  Â  Â  Â Bool Â  Â  Â  Â  Â  Â  Â  -- True <=> '!' specified</div><div><br></div><div>  Â  Â  | HsNoBang Â  Â  Â  Â  Â  Â  Â -- Lazy field</div><div>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  -- HsUserBang Nothing False means the same as HsNoBang</div><div><br></div><div>  Â  Â  | HsUnpack Â  Â  Â  Â  Â  Â  Â -- Definite commitment: this field is strict and unboxed</div><div>  Â  Â  Â  Â  Â (Maybe Coercion) Â  -- Â  Â co :: arg-ty ~ product-ty</div><div><br></div><div>  Â  Â  | HsStrict Â  Â  Â  Â  Â  Â  Â -- Definite commitment: this field is strict but not unboxed</div><br>This data type is a bit unclear to me:<br><br> * What are the reasons for the following constructor overlaps?<br>  Â * `HsNoBang` and `HsUserBang Nothing False`<br>  Â * `HsStrict` and `HsUserBang Nothing True`<br>  Â * `HsUnpack mb_co` and `HsUserBang (Just True) True`<div><br>* Why is there a coercion in `HsUnpack` but not in `HsUserBang (Just True) True`?</div><div><br><div>* Is there a difference in what the user wrote in the case of HsUserBang and HsNoBang/HsUnpack/HsStrict e.g are the latter three generated by the compiler as opposed to being written by the user (the function documentation notwithstanding)?<br><br>A very related function is isBanged:<br><br><div>  Â  isBanged :: HsBang -> Bool</div><div>  Â  isBanged HsNoBang Â  Â  Â  Â  Â  Â  Â  Â  Â = False</div><div>  Â  isBanged (HsUserBang Nothing bang) = bang</div><div>  Â  isBanged _ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  = True</div><div><br></div><div>What's the meaning of this function? Is it intended to communicate what the user wrote or whether result of what the user wrote results in a strict function?</div><br>Context: I'm adding a new StrictData language pragma [1] that makes fields strict by default and a '~' annotation of fields to reverse the default behavior. My intention is to change HsBang like so:<br><br>  Â  - Â  Â  Â  Bool Â  Â  Â  Â  Â  Â  Â  -- True <=> '!' specified<br>  Â  + Â  Â  Â  (Maybe Bool) Â  Â  Â  -- True <=> '!' specified, False <=> '~'<br>  Â  + Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â -- specified, Nothing <=> unspecified<br><br>1. <a href="https://ghc.haskell.org/trac/ghc/wiki/StrictPragma" target="_blank">https://ghc.haskell.org/trac/ghc/wiki/StrictPragma</a></div><span><font color="#888888"><div><br>-- Johan<br></div></font></span></div></div>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/ghc-devs" target="_blank">http://www.haskell.org/mailman/listinfo/ghc-devs</a><br>
<br></blockquote></div><br></div>