Make fromFunction results shallower

Construct the results of `fromFunction` so they have the same
shape as the results of `replicate`. Make `fromFunction` a bit
easier to read.