laszlopandy/elm-console/1.0.1

NOTE: this package is not compatible with Elm 0.19.1

Console

A library for writing terminal-based scripts in elm. The IO type provides an interface for constructing "computations" that may perform IO effects. Something with type IO a is a lazy computation that when run will produce an a, possibly IO side effects. See Console.Runner for how to run such a computation.

IO Type

type alias IO a =
IO a

An IO a is a computation that does some I/O and eventually returns an a

run : IO () -> Signal (Task x ())

Run an IO computation as a Task

Stdout

putChar : Char -> IO ()

Print a character to stdout

putStr : String -> IO ()

Print a string to stdout.

putStrLn : String -> IO ()

Print a string to stdout, followed by a newline.

Stdin

getChar : IO Char

Read a character from stdin

getLine : IO String

Read a line from stdin

readUntil : Char -> IO String

Read characters from stdin until one matches the given character.

File Operations

{ file : String
, content : String
}
-> IO ()

Write content to a file

Exit code

exit : Int -> IO ()

Exit the program with the given exit code.

Plumbing

map : (a -> b) -> IO a -> IO b

Apply a pure function to an IO value

mapIO : (a -> IO ()) -> List a -> IO ()

Alternative interface to forEach

forEach : List a -> (a -> IO ()) -> IO ()

Run an IO computation for each element of a list

pure : a -> IO a

Use a pure value where an IO computation is expected.

apply : IO (a -> b) -> IO a -> IO b

Apply an IO function to an IO value

(<*>) : IO (a -> b) -> IO a -> IO b

Convenient operator for apply, similar to ~ in the Signal module

andThen : IO a -> (a -> IO b) -> IO b

Chain together IO computations

(>>=) : IO a -> (a -> IO b) -> IO b

Operator version of andThen

seq : IO a -> IO b -> IO b

Run one computation and then another, ignoring the first's output

(>>>) : IO a -> IO b -> IO b

Operator version of seq

forever : IO a -> IO ()

Run the same computation over and over again forever.