
26 Jan
2021
26 Jan
'21
4:31 p.m.
I'm following this https://wiki.haskell.org/99_questions/Solutions/7 and yet I see this solution data NestedList a = Elem a | List [NestedList a] deriving (Show) flatten1 :: NestedList a -> [a] flatten1 (Elem a ) = [a] flatten1 (List (x:xs)) = flatten1 x ++ flatten1 (List xs) flatten1 (List []) = [] What I find puzzling is this line flatten1 (List (x:xs)) = flatten1 x ++ flatten1 (List xs) where I see (List (x:xs)) as an argument. How is the NestedList type also able to be expressed as a normal consed list with x:xs argument? How is (:) interacting with NestedList? LB