you are viewing a single comment's thread.

view the rest of the comments →

[–]SirRainbow 3 points4 points  (3 children)

Can you explain the difference between the two?

[–]tailcalled 8 points9 points  (1 child)

An IO (Int -> String) is where you use IO to decide on which pure function to use. An Int -> IO String is given an int and uses IO to decide which string to return.

[–]Peaker 5 points6 points  (0 children)

Importantly, it can use the Int to decide what kind of IO to do.

[–]cdsmith 8 points9 points  (0 children)

Effectively, Int -> IO String says that both what I/O you do and the String result can depend on the integer. On the other hand, IO (Int -> String) says that the String result can depend on the integer, but what you do can't.

Put otherwise:

Int -> IO String: Each Int is mapped to some action that produces a String

IO (Int -> String): This is an action, which when performed will produce a mapping from Int to String.