<div dir="ltr">I rather like this version. It avoids needlessly holding onto the entire list from the start, unlike the original version, which is leakier, and avoids the unnecessary strictness problem of the second version. <div><br></div><div>We should definitely keep the original in a comment as a description of the meaning of the operator, with an explanation of the change, though, as the road here is rather convoluted, and to Andreas' point it is far easier to understand even if it has undesirable garbage collection properties.</div><div><div><br></div><div>-Edward</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 5, 2018 at 3:00 AM, Chris Wong <span dir="ltr"><<a href="mailto:lambda.fairy@gmail.com" target="_blank">lambda.fairy@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="auto"><div>The proposed definition has one drawback: it is strict in its second argument.</div><div dir="auto"><br></div><div dir="auto">It should be possible to make it lazy in its second argument while keeping the single-pass behavior, though. Something like this?</div><div dir="auto"><br></div><div dir="auto">ZipList xs <|> ZipList ys = ZipList $ go xs ys 0</div><div dir="auto">  where</div><div dir="auto">    go [] ys n = drop n ys</div><div dir="auto">    go (x:xs) ys n = x : (go xs ys $! n + 1)<br><br><div class="gmail_quote" dir="auto"><div><div class="h5"><div dir="ltr">On Tue, Jun 5, 2018, 15:36 박신환 <<a href="mailto:ndospark320@naver.com" target="_blank">ndospark320@naver.com</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div><div style="font-size:10pt;font-family:Gulim,sans-serif"><p><span style="font-family:courier new,serif">Current definion of (<|>) for ZipLists:</span><span></span></p><pre><span style="font-family:gulim,sans-serif"></span><a href="http://hackage.haskell.org/package/base-4.11.1.0/docs/src/Control.Applicative.html#ZipList" rel="noreferrer" target="_blank"><span class="m_1808369083523826379m_7228922599614306802hs-identifier m_1808369083523826379m_7228922599614306802hs-var" style="font-family:courier new,serif">ZipList</span></a><span style="font-family:courier new,serif"> </span><a name="m_1808369083523826379_m_7228922599614306802_local-6989586621679319881" rel="noreferrer"></a><a href="http://hackage.haskell.org/package/base-4.11.1.0/docs/src/Control.Applicative.html#local-6989586621679319881" rel="noreferrer" target="_blank"><span class="m_1808369083523826379m_7228922599614306802hs-identifier" style="font-family:courier new,serif">xs</span></a><span style="font-family:courier new,serif"> </span><a name="m_1808369083523826379_m_7228922599614306802_local-8214565720323792760" rel="noreferrer"></a><a href="http://hackage.haskell.org/package/base-4.11.1.0/docs/src/GHC.Base.html#%3C%7C%3E" rel="noreferrer" target="_blank"><span class="m_1808369083523826379m_7228922599614306802hs-operator" style="font-family:courier new,serif"><|></span></a><span style="font-family:courier new,serif"> </span><a href="http://hackage.haskell.org/package/base-4.11.1.0/docs/src/Control.Applicative.html#ZipList" rel="noreferrer" target="_blank"><span class="m_1808369083523826379m_7228922599614306802hs-identifier m_1808369083523826379m_7228922599614306802hs-var" style="font-family:courier new,serif">ZipList</span></a><span style="font-family:courier new,serif"> </span><a name="m_1808369083523826379_m_7228922599614306802_local-6989586621679319882" rel="noreferrer"></a><a href="http://hackage.haskell.org/package/base-4.11.1.0/docs/src/Control.Applicative.html#local-6989586621679319882" rel="noreferrer" target="_blank"><span class="m_1808369083523826379m_7228922599614306802hs-identifier" style="font-family:courier new,serif">ys</span></a><span style="font-family:courier new,serif"> </span><span class="m_1808369083523826379m_7228922599614306802hs-glyph" style="font-family:courier new,serif">=</span><span style="font-family:courier new,serif"> </span><a href="http://hackage.haskell.org/package/base-4.11.1.0/docs/src/Control.Applicative.html#ZipList" rel="noreferrer" target="_blank"><span class="m_1808369083523826379m_7228922599614306802hs-identifier m_1808369083523826379m_7228922599614306802hs-var" style="font-family:courier new,serif">ZipList</span></a><span style="font-family:courier new,serif"> </span><span class="m_1808369083523826379m_7228922599614306802hs-special" style="font-family:courier new,serif">(</span><a href="http://hackage.haskell.org/package/base-4.11.1.0/docs/src/Control.Applicative.html#local-6989586621679319881" rel="noreferrer" target="_blank"><span class="m_1808369083523826379m_7228922599614306802hs-identifier m_1808369083523826379m_7228922599614306802hs-var" style="font-family:courier new,serif">xs</span></a><span style="font-family:courier new,serif"> </span><a href="http://hackage.haskell.org/package/base-4.11.1.0/docs/src/GHC.Base.html#%2B%2B" rel="noreferrer" target="_blank"><span class="m_1808369083523826379m_7228922599614306802hs-operator m_1808369083523826379m_7228922599614306802hs-var" style="font-family:courier new,serif">++</span></a><span style="font-family:courier new,serif"> </span><a href="http://hackage.haskell.org/package/base-4.11.1.0/docs/src/GHC.List.html#drop" rel="noreferrer" target="_blank"><span class="m_1808369083523826379m_7228922599614306802hs-identifier m_1808369083523826379m_7228922599614306802hs-var" style="font-family:courier new,serif">drop</span></a><span style="font-family:courier new,serif"> </span><span class="m_1808369083523826379m_7228922599614306802hs-special" style="font-family:courier new,serif">(</span><a href="http://hackage.haskell.org/package/base-4.11.1.0/docs/src/Data.Foldable.html#length" rel="noreferrer" target="_blank"><span class="m_1808369083523826379m_7228922599614306802hs-identifier m_1808369083523826379m_7228922599614306802hs-var" style="font-family:courier new,serif">length</span></a><span style="font-family:courier new,serif"> </span><a href="http://hackage.haskell.org/package/base-4.11.1.0/docs/src/Control.Applicative.html#local-6989586621679319881" rel="noreferrer" target="_blank"><span class="m_1808369083523826379m_7228922599614306802hs-identifier m_1808369083523826379m_7228922599614306802hs-var" style="font-family:courier new,serif">xs</span></a><span class="m_1808369083523826379m_7228922599614306802hs-special" style="font-family:courier new,serif">)</span><span style="font-family:courier new,serif"> </span><a href="http://hackage.haskell.org/package/base-4.11.1.0/docs/src/Control.Applicative.html#local-6989586621679319882" rel="noreferrer" target="_blank"><span class="m_1808369083523826379m_7228922599614306802hs-identifier m_1808369083523826379m_7228922599614306802hs-var" style="font-family:courier new,serif">ys</span></a><span class="m_1808369083523826379m_7228922599614306802hs-special" style="font-family:courier new,serif">)</span><span style="font-family:courier new,serif"><br><br>doesn't work if the left argument is infinite. It should be:<br><br>ZipList []     <|> ys             = ys<br>xs             <|> ZipList []     = xs<br>ZipList (x:xs) <|> ZipList (_:ys) = ZipList (x : (ZipList xs <|> ZipList ys))<br></span></pre></div></div><table style="display:none"><tbody><tr><td><img src="https://mail.naver.com/readReceipt/notify/?img=JqRCbHFTpz%2FYaqgZKrRZF4tlFx0opzMdM4ivFzk0FrtmpzJvKrt%2Fax%2BSM4k4FuIo%2BrkSKob5W4d5W4C5bX0q%2BzkR74FTWx%2FsWz0Sb4JZ16kqtzCCbrR0Wzm5WXiN.gif" border="0"></td></tr></tbody></table></div></div><span class="">______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" rel="noreferrer" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/libraries</a><br>
</span></blockquote></div></div></div>
<br>______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div>