#1543: flag to define transpose [] == _|_
------------------------------+---------------------------------------------
  Reporter:  guest            |          Owner:         
      Type:  feature request  |         Status:  new    
  Priority:  normal           |      Milestone:         
 Component:  Compiler         |        Version:  6.6.1  
  Severity:  minor            |       Keywords:         
Difficulty:  Unknown          |             Os:  Unknown
  Testcase:                   |   Architecture:  Unknown
------------------------------+---------------------------------------------
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.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1543>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to