Reading String data into a Tree like nested grid structure (like Sudoku Board)
Consider the polymorphic function:

axis :: [a] -&gt; Axis a
axis [x,y,z] = Axis x y z


You want to apply this at each of the four "list levels" of the output [[[[a]]]] of nestList.  So, if you have:

lst4 : [[[[Char]]]]
lst4 = nestList "295743861431865927876192543387459216612387495549216738763534189928671354154938672"


you want to write:

axis lst4 :: Axis [[[Char]]]


to replace the outermost list with an Axis, then you want to fmap axis over the Axis:

fmap axis . axis $ lst4 :: Axis (Axis [[Char]])


to replace the second-level list with an Axis, then you want to do a double-fmap (fmap axis):

fmap (fmap axis) . fmap axis . axis $ lst4 :: Axis (Axis (Axis [Char]))


to replace the third-level list, and finally the innermost list:

fmap (fmap (fmap axis)) . fmap (fmap axis) . fmap axis . axis $ lst4 :: Axis (Axis (Axis (Axis Char)))


So, you actually have:

axify :: [[[[a]]]] -&gt; Board a
axify = fmap (fmap (fmap axis)) . fmap (fmap axis) . fmap axis . axis


Alternatively, instead of using the functor instance for Axis, you could use the functor instance for lists, starting from the inside out:

axify = axis . map axis . map (map axis) . map (map (map axis))