is identity the only polymorphic function without typeclasses?
Sun, 02 Mar 2003 21:37:50 -0600
Cagdas Ozgenc <firstname.lastname@example.org> wrote:
> Is identity function the only meaningful function one can write
> without constraining the type variable using a typeclass? If not,
> could you please give a counter-example?
Certainly you can write lots of ``meaningful function''s without type
classes: not, (&&), (||), as well as many more complicated functions at
more complicated types.
You can also write useful polymorphic functions without type classes, as
long as you specify at least one type. For example, you can write
polymorphic functions over/yielding lists, such as repeat, cycle, map
and its many relatives, foldr and its many relatives, take and its
relatives, takeWhile and its relatives, etc. Similar functions often
exist for other types.
I'm somewhat curious, though: why do you ask this question? How do you
expand your question that makes the answer seem to be ``no''?