flag to define transpose [] == _|_
I use transpose a lot as an "unzip" function for lists. For example, suppose:
foo :: [[String]]
is a list of rows (say, of lenght 2) obtained from a SQL query. To transform it into a list of 2 columns, I simply write transpose foo. But, if foo is empty, I obtain... [[],[]]? No, I obtain []. I want the program to raise an error and stop, instead of (perhaps) produce a pattern match failure later, because transpose [] can arguably be [[]] or [[],[]] or [[],[],[]] or ... at least in some situations where it is used to "unzip" lists of lists.
I could use foo :: [(String, String)] or foo :: [(String, String, String)] etc., but [ [String]] is simpler and more general, and I can use map, etc.
Trac metadata
Trac field | Value |
---|---|
Version | 6.6.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | Unknown |
Architecture | Unknown |