wraps [] around each top-level element of list
问题 wrap [1,2,3] should output [[1],[2],[3]] wrap [[1],[2],[3]] should output [ [[1]], [[2]], [[3]] ] my implementation is: wrap [] = [] wrap (x:xs) = [x] : [wrap xs] and haskell output an error: Occurs check: cannot construct the infinite type: t ~ [t] Expected type: [t] -> [t] Actual type: [t] -> [[t]] 回答1: [wrap xs] wraps the entire result of wrap xs . You don't want to wrap the entire result. You only want to wrap each individual element of the remainder of the list and that is exactly what