At Haskell, we have the IO monad to deal with side effects, although it is not able to express expressive side effects, you really don't know what type of side effect is actually happening:
main :: IO ()
In PureScript, we have the Eff monad, where you can find out which side effects occur according to a signature like:
main :: forall e. Eff (fs :: FS, trace :: Trace, process :: Process | e) Unit
Here it is obvious that the main function uses the file system, monitors messages on the console and can process the current process, where we have a special Control.Monad.Eff module for solving side effects and submodules such as Control.Monad.Eff.Random and Control.Monad.Eff.Console .
Taking the following as an example:
module RandomExample where import Prelude import Control.Monad.Eff import Control.Monad.Eff.Random (random) import Control.Monad.Eff.Console (print) printRandom :: forall e. Eff (console :: CONSOLE, random :: RANDOM | e) Unit printRandom = do n <- random print n
This is much more specific than using only "Hey, there is a side effect here, which he is, no more than what you need to know!". I am browsing the internet and I have not seen the monad complete enough to track side effects.
Is there a specific monad in Haskell, like Eff , for tracking side effects?
Thanks in advance.
haskell monads
Marcelo camargo
source share