Thanks for the insights. So what then does the t a part mean? In the simpler version t a is [a]. Is t some container? It's not meant to be a function, is it?

On Tue, Aug 3, 2021 at 5:39 PM Francesco Ariis <fa-ml@ariis.it> wrote:
Hello Lawrence,

Il 03 agosto 2021 alle 17:14 Galaxy Being ha scritto:
> According to this <http://zvon.org/other/haskell/Outputprelude/elem_f.html>
> elem is
>
> Eq a => a -> [a] -> Bool
>
> but according to my ghci :t it's this
>
> elem :: (Foldable t, Eq a) => a -> t a -> Bool
>
> I understand the first, but not the second, especially with the t. What is
> this saying extra, different from the first one?

Yup, some years ago there was a shift of some functions — after
a big discussion, as there were a few controversial changes — from
«working on lists only» to «working on all instances of some
class» (in this case: Foldable, alias «data structures that can
be folded») [1].

What is there for you? You gain the ability to use `elem` on
other structures than lists (e.g. Trees).
If you — like me — do not fancy reading signatures with too many
typeclasses, you can always use +d in ghci to default to concrete
types:

    λ> :t foldr
    foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b
    λ> :t +d foldr
    foldr :: (a -> b -> b) -> b -> [a] -> b

[1] https://wiki.haskell.org/Foldable_Traversable_In_Prelude
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


--

Lawrence Bottorff
Grand Marais, MN, USA
borgauf@gmail.com