Total beginner as you might have guessed. I've gone through "Learn you a Haskell" but I still struggle with even the basics.
I'm looking at this thread Split a number into its digits with Haskell and things start to make sense with this function
digits :: Integer -> [Int]
digits n = map (\x -> read [x] :: Int) (show n)
asked by Daniel.
I understand that show returns my input number as a String, or list of Chars, which then I can modify element by element using map. So, each "x", as a Char, is picked by the anonymous function and read as an Integer and the new list is composed by map, containing all the read integers. Shouldn't then read [x] be read x? Why does every read Char in the list need to be returned as it's own singleton list? It seems to me that this way calling digits 123 should return [[1],[2],[3]], since map will compose everything into a new list anyway and not [1,2,3] as it correctly does. But why?