Internal.Effect.IO a
return : a -> IO a
map : (a -> b) -> IO a -> IO b
do : IO a -> (a -> IO b) -> IO b
Compose IO actions, do-notation style.
do (File.open "file.txt" |> exitOnError identity) <| \fd ->
do (File.write fd "Hello, World")
andThen : (a -> IO b) -> IO a -> IO b
Compose IO actions, andThen
style
File.open "file.txt"
|> exitOnError identity
|> andThen
(\fd ->
File.write fd "Hello, World"
)
combine : List (IO a) -> IO (List a)
Perform IO in sequence
exitOnError : (error -> String) -> IO (Result error a) -> IO a
Print to stderr and exit program on Err
{ argv : List String
, pid : Basics.Int
, env : Dict String String
}
program : (Process -> IO ()) -> Internal.Program.PosixProgram
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
Internal.Program.PosixProgram