Thursday, November 30, 2023

[iuigljdm] and (False,True)

some more silliness resulting from the Foldable Traversable Proposal (FTP) in Haskell:

*Main> and (False,True)
*Main> and [False,True]
*Main> uncurry (&&) (False,True)
*Main> snd (False,True)

"and" may be called on a tuple because tuples are instances of Foldable.  this is similar to length (1,2) == 1.

"and" == "snd" was discovered by accident.  I had accidentally typed "and" instead of "snd" (A and S are adjacent on a QWERTY keyboard), calling it on an argument of type (a,Bool).  despite the typo, seemingly substituting functions of completely different types, the program compiled and ran successfully.  I think "and" and "snd" always give the same answer for inputs of type (a,Bool).

No comments :