I went to check why the hell this happened. It looks like the pair (“(,)”) is defined as an instance of Foldable, for some reason, which is the class used by functions like foldl() and foldr(). Meanwhile, triples and other tuples of higher order (such as triples, quadruples, …) are not instances of Foldable.
The weirdest part is that, if you try to use a pair as a Foldable, you only get the second value, for some reason… Here is an example.
(.) is a valid expression in Haskell. Normally it is the prefix form of the infix operator . that does function
composition. (.) (2*) (1+) 3 = ((2*) . (1+)) 3 = 2 * (1 + 3) = 8.
But, the most common use of the word “boob” in my experience in Haskell is the “boobs operator”: (.)(.). It’s usage in Haskell is limited (tho valid), but it’s appearance in racy ASCII art predates even the first versions on Haskell.
Oddly enough, in Haskell (as defined by the report), length is monomorphic, so it just doesn’t work on tuples (type error).
Due to the way kinds (types of types) work in Haskell, Foldable instances can only operate over (i.e. length only counts) elements of the last/final type argument. So, for (,) it only counts the second part, which is always there exactly once. If you provided a Foldable for (,) it would also have length of 1.
Wait, now I need to know why.
* some time later *
I went to check why the hell this happened. It looks like the pair (“
(,)
”) is defined as an instance ofFoldable
, for some reason, which is the class used by functions likefoldl()
andfoldr()
. Meanwhile, triples and other tuples of higher order (such as triples, quadruples, …) are not instances ofFoldable
.The weirdest part is that, if you try to use a pair as a
Foldable
, you only get the second value, for some reason… Here is an example.ghci> foldl (\acc x -> x:acc) [] (1,2) [2]
This makes it so that the returned length is 1.
I don’t even know Haskell but it seems like (" ( , ) ") would be an instance of boob.
(.)
is a valid expression in Haskell. Normally it is the prefix form of the infix operator.
that does function composition.(.) (2*) (1+) 3
=((2*) . (1+)) 3
=2 * (1 + 3)
=8
.But, the most common use of the word “boob” in my experience in Haskell is the “boobs operator”:
(.)(.)
. It’s usage in Haskell is limited (tho valid), but it’s appearance in racy ASCII art predates even the first versions on Haskell.The pioneers of ASCII art in the 70s and 80s are the unsung heroes of porn.
Oddly enough, in Haskell (as defined by the report), length is monomorphic, so it just doesn’t work on tuples (type error).
Due to the way kinds (types of types) work in Haskell, Foldable instances can only operate over (i.e. length only counts) elements of the last/final type argument. So, for (,) it only counts the second part, which is always there exactly once. If you provided a Foldable for (,) it would also have length of 1.