Q:

list containing the second elements of the list members in haskell

I am trying to do solve a old midterm problem from a previous year and I having a lot of trouble with this one. 
Using list comprehension, implement a function with the following type:
collectSecond :: [[Int]] -> [Int]

such that (collectSecond xs) returns a list containing the second elements of the list members of xs, except for those list members with a length less than two.  For example:
collectSecond [[1,2,3], [4], [], [5,6]] ~> [2,6]
collectSecond [[1], [], [2]] ~> []
collectSecond [] ~> []

Any help with this would be greatly appreciated. 

A:

You can use pattern matching in the list comprehension to get out the second element like so:
collectSecond xs = [x2 |  x1:x2:rest <-  xs]

Here x2 matches to the second element of each of lists that xs contains, if any.   
Prelude> collectSecond [[1,2,3], [4], [], [5,6]]
[2,6]

And if there is no second element, then no element is added to the list for that sub list.   See the [4] and [] in above example for instance.