Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't you get the length of (,,)?

Tags:

haskell

length (1,2) 

returns a result, but

length (1, 2, 3)

gives an error. Why is that?

Reading the types of (,) and (,,) did not help.

Edit: I'm thinking of the length from Data.Foldable length :: Foldable t => t a -> Int

like image 770
The Unfun Cat Avatar asked Jan 31 '26 21:01

The Unfun Cat


1 Answers

The Functor, Traversable, and most especially Foldable instances for pairs are somewhat controversial. There are circumstances where they allow code to compile and do something that was not intended. I proposed adding the missing functor instances for triples, etc. and, as the ensuing threads show, that really touched a nerve. So why doesn't (,,) have a Foldable instance? Because the community hasn't reached a consensus that it should.

like image 125
dfeuer Avatar answered Feb 02 '26 13:02

dfeuer