You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to #157, it is now rather difficult, if not impossible, to write a function that doesn't expect to return the same result every time for the same arguments. For example, let's assume there's some function that reads a line from a Reader, such as readLine. Before #157,
let x => readLine io.stdin;
io.stdout
-> io.writeln x
-> io.writeln x
;
would have read and then written two successive lines from and to stdin and stdout, respectively. Because of #157, however, only one line is read. However, what if the old behavior is the intended behavior? It's now not possible to create a function that does different things each time it's called.
The solution I'm leaning towards right now is to add a new function modifier, impure, which specifies that the results of the function should not be cached. It's essentially the opposite of memo. If the above had had the line let impure x => readLine io.stdin; instead, then it would have used the old behavior.
An alternative would be to take copy Haskell and make I/O a unique type of operation, but I'd rather leave things up to the user as much as possible. As such, another function modifier that might be useful is something like immediate or imperative, which would cause an expression to be evaluated at the time that it's placed into the scope, rather than when it's gotten later. This could be useful to make sure that things are evaluated in the intended order.
The text was updated successfully, but these errors were encountered:
Due to #157, it is now rather difficult, if not impossible, to write a function that doesn't expect to return the same result every time for the same arguments. For example, let's assume there's some function that reads a line from a
Reader
, such asreadLine
. Before #157,would have read and then written two successive lines from and to stdin and stdout, respectively. Because of #157, however, only one line is read. However, what if the old behavior is the intended behavior? It's now not possible to create a function that does different things each time it's called.
The solution I'm leaning towards right now is to add a new function modifier,
impure
, which specifies that the results of the function should not be cached. It's essentially the opposite ofmemo
. If the above had had the linelet impure x => readLine io.stdin;
instead, then it would have used the old behavior.An alternative would be to take copy Haskell and make I/O a unique type of operation, but I'd rather leave things up to the user as much as possible. As such, another function modifier that might be useful is something like
immediate
orimperative
, which would cause an expression to be evaluated at the time that it's placed into the scope, rather than when it's gotten later. This could be useful to make sure that things are evaluated in the intended order.The text was updated successfully, but these errors were encountered: