Re[2]: Ввод-вывод и чистые функции
От: AlexRK  
Дата: 23.01.17 21:21
Оценка:
Здравствуйте, deniok, Вы писали:

ARK>>Вы за какой вариант, с явно видимым в сигнатуре функции вводом-выводом, а-ля Хаскель, или с неявным, а-ля Ц++? Почему?


D>В Haskell:

D>(1) нет стека вызовов;
D>(2) нет типов в рантайме.

Хорошо, пусть будет Clean, вопрос совершенно не в этом.

D>Так что засорять нечего и нечем.


Ну да, конечно же нечего и нечем.

https://www.haskell.org/tutorial/io.html

getChar :: IO Char


The return function admits an ordinary value such as a boolean to the realm of I/O actions. What about the other direction? Can we invoke some I/O actions within an ordinary expression? For example, how can we say x + print y in an expression so that y is printed out as the expression evaluates? The answer is that we can't! It is not possible to sneak into the imperative universe while in the midst of purely functional code. Any value `infected' by the imperative world must be tagged as such. A function such as

f :: Int -> Int -> Int

absolutely cannot do any I/O since IO does not appear in the returned type.

 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.