[GHC] #14187: Transpose hangs on infinite by finite lists

GHC ghc-devs at haskell.org
Wed Sep 6 13:45:00 UTC 2017


#14187: Transpose hangs on infinite by finite lists
-------------------------------------+-------------------------------------
        Reporter:  utikeev           |                Owner:  (none)
            Type:  bug               |               Status:  closed
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.1
      Resolution:  invalid           |             Keywords:  transpose
Operating System:  Windows           |         Architecture:  x86_64
 Type of failure:  Runtime           |  (amd64)
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by nomeata):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 Thanks for your report.

 This is expected behavior. Note that the documentation says

 > The transpose function transposes the rows and columns of its argument.
 For example,
 >
 > transpose [[1,2,3],[4,5,6]] == [[1,4],[2,5],[3,6]]
 >
 > If some of the rows are shorter than the following rows, their elements
 are skipped:
 >
 > transpose [[10,11],[20],[],[30,31,32]] == [[10,20,30],[11,31],[32]]

 Note that `repeat [0,1] = [[0,1],[0,1],[0,1],[0,1],[0,1],…`.

 So if you look at the third element of `transpose (repeat [0,1])` then it
 has to skip the first `[0,1]` in the list of lists, as it has no third
 element. Then it skips the second, for the same reason, and goes on like
 that for ever.

 (You might wonder why it doesn’t detect that, because you use `repeat`,
 that _no_ element in the list has a third element – but that kind of
 reasoning is beyond what you can expect from a compiler, unfortunately.)

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14187#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list