Compose IO actions, do-notation style.
do (File.open "file.txt" |> exitOnError identity) <| \fd ->
do (File.write fd "Hello, World")
Compose IO actions, andThen
style
File.open "file.txt"
|> exitOnError identity
|> andThen
(\fd ->
File.write fd "Hello, World"
)
Perform IO in sequence
Print to stderr and exit program on Err
module HelloUser exposing (program)
import Dict exposing (Dict)
import Posix.IO as IO exposing (IO, Process)
import Posix.IO.File as File
helloUser : Process -> IO ()
helloUser process =
let
userName =
Dict.get "USER" process.env
|> Maybe.withDefault "Unknown"
in
File.write File.stdOut userName
program : IO.PosixProgram
program =
IO.program helloUser