elm-script icon indicating copy to clipboard operation
elm-script copied to clipboard

Add stream support

Open ianmackenzie opened this issue 6 years ago • 1 comments

Have InputStream and OutputStream types that allow streaming I/O on files, standard in, standard out etc.

Allow converting File values into corresponding streams:

File.toInputStream : File (Read p) -> InputStream
File.toOutputStream : File (Write p) -> OutputStream

Add stdin and stdout to Context:

type alias Context =
    { arguments : List String
    , ...
    , stdin : InputStream
    , stdout : OutputStream
    }

Have Stream module with various ways to read from/write to streams:

Stream.write : String -> OutputStream -> Script Stream.Error ()
Stream.read : InputStream -> Script Stream.Error String

Stream.read might need to be a bit more sophisticated to be able to cleanly detect when the end of the stream has been reached...

ianmackenzie avatar Oct 26 '17 15:10 ianmackenzie

Perhaps simpler: expose stdin and stdout as File objects?

ianmackenzie avatar Dec 12 '19 02:12 ianmackenzie