Why is it possible to sleep / pause execution in Haskell if it's purely functional?

后端 未结 3 1575
挽巷
挽巷 2021-02-01 04:31

I saw Haskell has a sleep function called \"delay\": Control.Concurrent.Thread.Delay

My question is: if Haskell is purely functional, how is it possible to have

3条回答
  •  萌比男神i
    2021-02-01 05:03

    A pure functional language shouldn't have the functions like "delay", "writeFile", etc. because they produce side effects. But Haskell has these functions and it deals with them by a container titled IO which is also a monad. IO hides all the side effects made by these functions.

提交回复
热议问题