<div dir="ltr"><div>I think what you're missing is what you actually typed in the first case.</div><div><br></div><div>This is a type error, it will not compile or run:</div><div><br></div>chopEnds = init $ tail<div><br></div><div>The $ operator can always be rewritten as parentheses, in this case:</div><div><br></div><div>chopEnds = init (tail)<br><div><br>Which has the same incorrectly typed meaning as:</div><div><br></div><div>chopEnds = init tail<br><div><div><br></div><div>The "result" you pasted looks equivalent to:</div><div><br></div><div>chopEnds = init</div><div><br></div><div>Perhaps this is what you typed? In this case the argument tail it will shadow the existing binding of the Prelude tail, which would be confusing so with -Wall it would issue a compiler warning:</div><div><br></div><div>chopEnds tail = init $ tail</div><div><br></div><div><interactive>:2:10: warning: [-Wname-shadowing]<br>    This binding for ‘tail’ shadows the existing binding<br>      imported from ‘Prelude’ (and originally defined in ‘GHC.List’)<br></div><div><br></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 25, 2021 at 10:16 AM Lawrence Bottorff <<a href="mailto:borgauf@gmail.com">borgauf@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">I've got this<div><br></div><div>> init $ tail [1,2,3]<br></div><div>[2]<br></div><div><br></div><div>and this</div><div><br></div><div>> chopEnds = init $ tail<br></div><div>> chopEnds [1,2,3]</div><div>[1,2]<br></div><div><br></div><div>What happened? Why is it not just init $ tail [1,2,3] ?</div><div><br></div><div>This works fine </div><div><br></div><div>> chopEnds2 = init . tail</div><div>> chopEnds2 [1,2,3]</div><div>[2]<br></div><div><br></div><div>What am I missing?</div><div><br></div><div>LB</div></div>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div>