Q:

How to read this functional code

Having trouble reading (interpreting) this functional Miranda code.
g = (foldr (+) 0) . (foldr ((:) . ((#) . (:[]))) [])

I know what it does

Calculate the size of a list by taking the length via #
Creating a one element list containing the above length of the original input list
Collapsing the new list using foldr into a single integer with the operation +0 on each element

However I am confused by the brackets and don't see where the input list is fed in. What does the rightmost [] constructor do?
Also why does this code only work via the function g, but if I call it directly it throws an error?

A:

In short, g is a function that returns the length of the list.
Let's break the function into some parts.
|| returns 1 for any input.
||   return_one "hoobar" = 1
return_one :: * -> num
return_one = (#) . (:[]) 

|| ignore first argument, insert 1 to the second argument.
||   insert_one "hoobar" [4,5,6] = [1,4,5,6]
insert_one :: *->[num]->[num]
insert_one = (:) . return_one

|| sum of list.
||   sum_list [7,8,9] = 24
sum_list :: [num] -> num 
sum_list = foldr (+) 0

|| generate list of 1 which as the same length of original list. 
||   change_one ["apple","banana"] = [1,1]
change_one :: [*] -> [num]
change_one = foldr insert_one []

|| return the length of the list.
||   g ["apple","banana"] = 2
g :: [*] -> num
g = sum_list . change_one

I would explain some confusing functions.
return_one
(:[]) is a function that creates single element list, and (#) returns the length.
Strictly speaking, (:[]) is (:) which takes [] as first argument.
therefore (:[]) "hoobar" = "hoobar":[] = ["hoobar"], and applying (#) to it returns 1.
change_one
It starts with empty list [] and traverses through the list with inserting 1 to the front.
foldr insert_one [] ["apple","banana"]
= foldr insert_one [1] ["apple"]
= foldr insert_one [1,1] []

