davidlazar/process-extras — pull request #5 by ddssff (2014-12-05 05:15:33+00:00)
Title: Use the ListLIke classes to generalize the readProcess functions

This pull request is in three steps:

1. GENERALIZED INPUT AND OUTPUT TYPE - Add readCreateProcessWithExitCode functions which take a CreateProcess instead of a FilePath and list of arguments. Make the readProcessWithExitCode functions calls to readCreateProcessWIthExitCode. Add a ListLikeProcessIO class and turn all the individual readCreateProcessWithExitCode functions into its instances. Add two utility functions: showCreateProcessForUser and showCmdSpecForUser. Add type specialized versions of the readProcessWithExitCode functions for backwards compatibility.

2. MERGE IMPLEMENTATIONS - Now the different implementations of readCreateProcessWithExitCode differ only in one place, where they force the process output. Replace the readCreateProcessWithExitCode method with a small forceOutput method, and add a general readCreateProcessWithExitCode function that works for all ListLikeProcessIO instances.

3. LAZINESS AND GENERALIZED RESULT TYPE - Add a readProcessLazy function. This needs a ProcessOutput class (ProcessResult might be a better name) whose methods turn the different pieces of process output (stdout, stderr, exit code, etc) into a monoid type. It also uses a new ListLikeProcessIO method named readChunks that turns the process output into a lazy list of chunks. Also added is a Chunk type which is a concrete representation of the process output methods in ProcessOutput. We can have a process output [Chunk a], then echo the chunks lazily to standard output, and then use collectOutput to convert the result to any ProcessOutput instance.