<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">The type of the last part of the expression is:<div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">many $ Just 1 :: Num a => Maybe [a]</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">So in order to be able to return the “Just” constructor which inspected by the application of (take 3 <$>) we have somehow to know for sure that all the <*> executions will indeed see a “Just” in both of their arguments. This forces more and more evaluations.</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  </span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> Doaitse</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><div><blockquote type="cite" class=""><div class="">Op 29 sep. 2016, om 22:28  heeft Jake <<a href="mailto:jake.waksbaum@gmail.com" class="">jake.waksbaum@gmail.com</a>> het volgende geschreven:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><pre style="top: -99px;" class="">take 3 $ many $ Just 1<br class=""><br class=""><font face="sans-serif" class="">doesn't type check. Did you mean this?</font><br class=""><br class="">take 3 <$> (many $ Just 1)</pre><pre style="top: -99px;" class=""><font face="sans-serif" class="">I think this may have something to do with t<span style="font-size:13px" class="">he </span></font><span style="font-family:sans-serif;font-size:13px" class="">default definition of many in the definition of </span><a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#Alternative" style="font-family:sans-serif;font-size:13px" class="">Alternative</a><span style="font-family:sans-serif;font-size:13px" class="">:</span><br class=""></pre><div class=""><pre class=""><span class="inbox-inbox-hs-identifier" style="color:rgb(7,54,66)">many</span> <span class="inbox-inbox-hs-glyph" style="color:rgb(220,50,47)">::</span> <a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627395956" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)" class=""><span class="inbox-inbox-hs-identifier inbox-inbox-hs-type" style="color:rgb(95,95,175)">f</span></a> <a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627395960" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)" class=""><span class="inbox-inbox-hs-identifier inbox-inbox-hs-type" style="color:rgb(95,95,175)">a</span></a> <span class="inbox-inbox-hs-glyph" style="color:rgb(220,50,47)">-></span> <a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627395956" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)" class=""><span class="inbox-inbox-hs-identifier inbox-inbox-hs-type" style="color:rgb(95,95,175)">f</span></a> <span class="inbox-inbox-hs-special" style="color:rgb(220,50,47)">[</span><a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627395960" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)" class=""><span class="inbox-inbox-hs-identifier inbox-inbox-hs-type" style="color:rgb(95,95,175)">a</span></a><span class="inbox-inbox-hs-special" style="color:rgb(220,50,47)">]</span>
<a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#many" class="inbox-inbox-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="inbox-inbox-hs-identifier" style="color:rgb(7,54,66)">many</span></a> <a class=""></a><a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627395964" class="inbox-inbox-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="inbox-inbox-hs-identifier" style="color:rgb(7,54,66)">v</span></a> <span class="inbox-inbox-hs-glyph" style="color:rgb(220,50,47)">=</span> <a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627395965" class="inbox-inbox-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="inbox-inbox-hs-var inbox-inbox-hs-identifier" style="color:rgb(7,54,66)">many_v</span></a>
<a class=""></a>  <span class="inbox-inbox-hs-keyword" style="color:rgb(175,0,95)">where</span>
<a class=""></a>    <a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627395965" class="inbox-inbox-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="inbox-inbox-hs-identifier" style="color:rgb(7,54,66)">many_v</span></a> <span class="inbox-inbox-hs-glyph" style="color:rgb(220,50,47)">=</span> <a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627395966" class="inbox-inbox-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="inbox-inbox-hs-var inbox-inbox-hs-identifier" style="color:rgb(7,54,66)">some_v</span></a> <a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#%3C%7C%3E" class="inbox-inbox-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="inbox-inbox-hs-var inbox-inbox-hs-operator" style="color:rgb(211,54,130)"><|></span></a> <a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#pure" class="inbox-inbox-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="inbox-inbox-hs-var inbox-inbox-hs-identifier" style="color:rgb(7,54,66)">pure</span></a> <span class="inbox-inbox-hs-special" style="color:rgb(220,50,47)">[</span><span class="inbox-inbox-hs-special" style="color:rgb(220,50,47)">]</span>
<a class=""></a>    <a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627395966" class="inbox-inbox-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="inbox-inbox-hs-identifier" style="color:rgb(7,54,66)">some_v</span></a> <span class="inbox-inbox-hs-glyph" style="color:rgb(220,50,47)">=</span> <span class="inbox-inbox-hs-special" style="color:rgb(220,50,47)">(</span><a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#fmap" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)" class=""><span class="inbox-inbox-hs-var inbox-inbox-hs-identifier" style="color:rgb(7,54,66)">fmap</span></a> <span class="inbox-inbox-hs-special" style="color:rgb(220,50,47)">(</span><span class="inbox-inbox-hs-glyph" style="color:rgb(220,50,47)">:</span><span class="inbox-inbox-hs-special" style="color:rgb(220,50,47)">)</span> <a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627395964" class="inbox-inbox-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="inbox-inbox-hs-var inbox-inbox-hs-identifier" style="color:rgb(7,54,66)">v</span></a><span class="inbox-inbox-hs-special" style="color:rgb(220,50,47)">)</span> <a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#%3C%2A%3E" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)" class=""><span class="inbox-inbox-hs-var inbox-inbox-hs-operator" style="color:rgb(211,54,130)"><*></span></a> <a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#local-1627395965" class="inbox-inbox-" style="text-decoration:none;border-bottom:1px solid rgb(238,232,213)"><span class="inbox-inbox-hs-var inbox-inbox-hs-identifier" style="color:rgb(7,54,66)">many_v</span></a>
</pre>many_v and some_v are mutually recursive functions, and it may be that this prevents the thunks from being made available to take in some way. I'm really not sure though, this is just an idea about why this is not quite the same as (take $ repeat 1)</div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Sep 29, 2016 at 3:51 PM Corentin Dupont <<a href="mailto:corentin.dupont@gmail.com" class="">corentin.dupont@gmail.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_quote"><div dir="ltr" class=""><div class="gmail_quote"><div dir="ltr" class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class="">Hi guys,<br class=""></div>I'm playing with the mysterious "some" and "many" from Control.Applicative.<br class=""></div>If I try: <br class=""><br class=""><span style="font-family:monospace,monospace" class="">many $ Just 1<br class=""><br class=""></span></div><span style="font-family:monospace,monospace" class=""><font face="arial,helvetica,sans-serif" class="">It just loops, I understand why:<br class=""><a href="http://stackoverflow.com/questions/18108608/what-are-alternatives-some-and-many-useful-for" target="_blank" class="">http://stackoverflow.com/questions/18108608/what-are-alternatives-some-and-many-useful-for</a><br class=""></font></span></div></div></div></div></div></div></div></div></div><div dir="ltr" class=""><div class="gmail_quote"><div dir="ltr" class=""><div class="gmail_quote"><div dir="ltr" class=""><div class=""><div class=""><div class=""><span style="font-family:monospace,monospace" class=""><font face="arial,helvetica,sans-serif" class="">It seems that some and many are usually used in a context where something is consumed, and can be depleted, so the loop ends.<br class=""><br class=""></font></span></div></div></div></div></div></div></div></div><div dir="ltr" class=""><div class="gmail_quote"><div dir="ltr" class=""><div class="gmail_quote"><div dir="ltr" class=""><div class=""><div class=""><span style="font-family:monospace,monospace" class=""><font face="arial,helvetica,sans-serif" class="">But why doesn't this terminates?<br class=""><br class=""></font></span></div></div></div></div></div></div></div><div dir="ltr" class=""><div class="gmail_quote"><div dir="ltr" class=""><div class="gmail_quote"><div dir="ltr" class=""><div class=""><span style="font-family:monospace,monospace" class="">take 3 $ many $ Just 1<br class=""></span><span style="font-family:arial,helvetica,sans-serif" class=""><br class=""></span></div></div></div></div></div></div><div dir="ltr" class=""><div class="gmail_quote"><div dir="ltr" class=""><div class="gmail_quote"><div dir="ltr" class=""><span style="font-family:arial,helvetica,sans-serif" class="">It's a recursive call, but the construction of the result should be lazy...<span class=""><font color="#888888" class=""><span class=""><font color="#888888" class=""><br class=""></font></span></font></span></span><span class=""><font color="#888888" class=""><span class=""></span></font></span><br class=""></div></div></div></div></div>
_______________________________________________<br class="">
Haskell-Cafe mailing list<br class="">
To (un)subscribe, modify options or view archives go to:<br class="">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">
Only members subscribed via the mailman list are allowed to post.</blockquote></div>
_______________________________________________<br class="">Haskell-Cafe mailing list<br class="">To (un)subscribe, modify options or view archives go to:<br class=""><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">Only members subscribed via the mailman list are allowed to post.</div></blockquote></div><br class=""></div></div></body></html>