<div dir="ltr">Thanks for the insights. So what then does the <font face="monospace">t a</font> part mean? In the simpler version<font face="monospace"> t a</font> is <font face="monospace">[a]</font>. Is <font face="monospace">t </font>some container? It's not meant to be a function, is it?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Aug 3, 2021 at 5:39 PM Francesco Ariis <<a href="mailto:fa-ml@ariis.it">fa-ml@ariis.it</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">Hello Lawrence,<br>
<br>
Il 03 agosto 2021 alle 17:14 Galaxy Being ha scritto:<br>
> According to this <<a href="http://zvon.org/other/haskell/Outputprelude/elem_f.html" rel="noreferrer" target="_blank">http://zvon.org/other/haskell/Outputprelude/elem_f.html</a>><br>
> elem is<br>
> <br>
> Eq a => a -> [a] -> Bool<br>
> <br>
> but according to my ghci :t it's this<br>
> <br>
> elem :: (Foldable t, Eq a) => a -> t a -> Bool<br>
> <br>
> I understand the first, but not the second, especially with the t. What is<br>
> this saying extra, different from the first one?<br>
<br>
Yup, some years ago there was a shift of some functions — after<br>
a big discussion, as there were a few controversial changes — from<br>
«working on lists only» to «working on all instances of some<br>
class» (in this case: Foldable, alias «data structures that can<br>
be folded») [1].<br>
<br>
What is there for you? You gain the ability to use `elem` on<br>
other structures than lists (e.g. Trees).<br>
If you — like me — do not fancy reading signatures with too many<br>
typeclasses, you can always use +d in ghci to default to concrete<br>
types:<br>
<br>
λ> :t foldr<br>
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b<br>
λ> :t +d foldr<br>
foldr :: (a -> b -> b) -> b -> [a] -> b<br>
<br>
[1] <a href="https://wiki.haskell.org/Foldable_Traversable_In_Prelude" rel="noreferrer" target="_blank">https://wiki.haskell.org/Foldable_Traversable_In_Prelude</a><br>
_______________________________________________<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><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>⨽<br></div>Lawrence Bottorff<div>Grand Marais, MN, USA</div><div><a href="mailto:borgauf@gmail.com" target="_blank">borgauf@gmail.com</a></div></div></div>