Others have already answered. I will just add a few more explanations.
To simplify the bit, the Haskell indent rule:
- Some keywords trigger a block of things (
where , let , do , case ... of ). - Find the first word after such keywords and pay attention to its indent. Name the column in which it is located.
- Adjust the line exactly on the vault to define a new record in the block.
- Begin the line after the rotation to continue the recording started in the previous lines.
- Start the line before the pivot point to end the block.
Hence,
where wordCount input = show (ls ++ " " ++ ws ++ " " ++ cs ++ "\n") where ls = lines input ws = length words input cs = length input
Actually mean
where { wordCount input = show (ls ++ " " ++ ws ++ " " ++ cs ++ "\n") ; where { -- same column, new entry ls = lines input ; -- same column, new entry ws = length words input ; -- same column, new entry cs = length input } }
which treats the second where as a separate definition not related to wordCount . If we print this more:
where { wordCount input = show (ls ++ " " ++ ws ++ " " ++ cs ++ "\n") where { -- after the pivot, same entry ls = lines input ; ws = length words input ; cs = length input } }
source share