Expanded Shell Commands

Expanded Shell Commands

Expand the GADT based shell command DSL to support a new operation, wc that will call the wc program to count the number of lines in a file. After you’ve added that, write a function with the type:

countLinesInMatchingFiles :: String -> ShellCmd FilePath [(FilePath, Int)]

The function should take a glob that can be passed to grep, and it should return a shell command that, given a path to a directory full of files, will output the name of each file that matched with grep, along with the number of lines in that file. Be sure to only return one output for each file, even if there are multiple matches within the file.

Hint 1

Some high level hint text

Hint 2

Some more detailed hint text

Hint 3

Even more detailed hint text

Solution

A complete solution for the exercise