<div dir="ltr">On Mon, Nov 7, 2016 at 4:02 PM, David Feuer <span dir="ltr"><<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
IO m *> n = IO (\ s -> case m s of (# new_s, a #) -> unIO ((const n) a) new_s)<br></blockquote><div> </div><div>From looking at the Applicative source, this appears to be correct. Why don't we use thenIO instead, which elides the "const" and has the form<br></div><div><pre style="color:rgb(0,0,0);background-color:rgb(253,246,227)"><a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#thenIO" class="gmail-" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">thenIO</span></a> <span class="gmail-hs-special" style="color:rgb(220,50,47)">(</span><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">IO</span> <a name="local-1627396262"></a><a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627396262" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">m</span></a><span class="gmail-hs-special" style="color:rgb(220,50,47)">)</span> <a name="local-1627396263"></a><a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627396263" class="gmail-" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">k</span></a> <span class="gmail-hs-glyph" style="color:rgb(220,50,47)">=</span> <span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">IO</span> <span class="gmail-hs-special" style="color:rgb(220,50,47)">(</span><span class="gmail-hs-glyph" style="color:rgb(220,50,47)">\</span> <a name="local-1627396264"></a><a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627396264" class="gmail-" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">s</span></a> <span class="gmail-hs-glyph" style="color:rgb(220,50,47)">-></span> <span class="gmail-hs-keyword" style="color:rgb(175,0,95)">case</span> <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627396262" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">m</span></a> <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627396264" class="gmail-" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">s</span></a> <span class="gmail-hs-keyword" style="color:rgb(175,0,95)">of</span> <span class="gmail-hs-special" style="color:rgb(220,50,47)">(</span><span class="gmail-hs-operator" style="color:rgb(211,54,130)">#</span> <a name="local-1627396265"></a><a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627396265" class="gmail-" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">new_s</span></a><span class="gmail-hs-special" style="color:rgb(220,50,47)">,</span> <span class="gmail-hs-identifier" style="color:rgb(7,54,66)">_</span> <span class="gmail-hs-operator" style="color:rgb(211,54,130)">#</span><span class="gmail-hs-special" style="color:rgb(220,50,47)">)</span> <span class="gmail-hs-glyph" style="color:rgb(220,50,47)">-></span> <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#unIO" class="gmail-" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">unIO</span></a> <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627396263" class="gmail-" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">k</span></a> <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627396265" class="gmail-" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">new_s</span></a><span class="gmail-hs-special" style="color:rgb(220,50,47)">)</span></pre></div><div><br></div><div>It doesn't look like thenIO is used or exported, which makes me think someone either forgot about it or there's some good reason that isn't documented. Obviously if things go as planned, the const gets reduced away at compile time, but it seems like if we have thenIO sitting there in the source we might as well use it and not have to worry about compile-time eta-reduction of (\_ -> k).</div><div><br></div><div>Will</div></div></div></div>