/* ----------------------------------------------------------------------------- Copyright 2019-2021 Kevin P. Barry Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ----------------------------------------------------------------------------- */ // Author: Kevin P. Barry [ta0kira@gmail.com] // A sink for writing data. // // Params: // - #x: The value type to be written. @value interface Writer<#x|> { write (#x) -> (#self) } // A sink that can be flushed. // // Params: // - #x: The value type to be written. @value interface BufferedWriter<#x|> { refines Writer<#x> flush () -> (#self) } // A sink that might perform a partial write. // // Params: // - #x: The value type to be written. @value interface BlockWriter<#x|> { // Write the data and return the size of what was written. writeBlock (#x) -> (Int) } // Basic output destinations. concrete BasicOutput { refines Append refines BufferedWriter // Immediately writes the data and flushes the buffer. @value writeNow (Formatted) -> (#self) // Standard output writer. @type stdout () -> (#self) // Standard error writer. @type stderr () -> (#self) // Crashes with the written data as the error when flushed. @type error () -> (#self) }