APIIO
IO
Permission for real native interaction, with structured errors and line data. Console owns the standard streams; File owns file handles. Generic byte IO uses Bytes.Source and Bytes.Sink rather than a shared handle.
Error
type Error = { kind : Kind , path : String , message : String }Source
A structured IO failure.
Fields
Instances:
Eq Error
Show Error
Kind
type Kind = NotFound | PermissionDenied | AlreadyExists | IsDirectory | NotDirectory | OtherSource
The kinds of operating-system failure a program can act on. Anything else
is Other, with the system’s own text in the error’s message. Match on the
kind for behaviour that is the same on every platform.
Constructors
Instances:
Eq Kind
Show Kind
Line
type Line = { text : String , ending : String }Source
One line of input and the exact terminator that ended it.
Fields
Instances:
Eq Line
Show Line
IO
effect IOSource
Interaction with the world outside the program. It has no operations of its
own: natives perform it, and only main and the interpreter can run it.
describeError
describeError : Error -> StringSource
The failure as path: reason. Known kinds use stable text rather than the
system’s, so they read the same on every platform; Other shows the
system message.
import IO exposing (Kind(..))
IO.describeError { kind = NotFound, path = "a.txt", message = "" } == "a.txt: no such file or directory"
IO.describeError { kind = Other, path = "b", message = "device busy" } == "b: device busy"
lineEnding
lineEnding : String -> StringSource
A raw line’s terminator: "\n", "\r\n", or "".
import IO
IO.lineEnding "abc\r\n" == "\r\n"
IO.lineEnding "abc" == ""
lineText
lineText : String -> StringSource
A raw line without its terminator, as readLine splits it.
import IO
IO.lineText "abc\r\n" == "abc"
IO.lineText "abc" == "abc"
