[Haskell-cafe] Monads

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Mon Oct 1 11:34:08 CEST 2012


"Albert Y. C. Lai" <trebla at vex.net> writes:

> On 12-09-30 06:33 PM, Jake McArthur wrote:
>> When discussing monads, at least, a side effect is an effect that is
>> triggered by merely evaluating an expression. A monad is an interface
>> that decouples effects from evaluation.
>
> I don't understand that definition. Or maybe I do subconsciously.
>
> I have
>
> s :: State Int ()
> s = do { x <- get; put (x+1) }
>
> Is there an effect triggered by merely evaluating s?
>
> I have
>
> m :: IO ()
> m = if True then putStrLn "x" else putChar 'y'
>
> Is there an effect triggered by merely evaluating m?
>
> What counts as "evaluate"?

Evaluation! Consider m `seq` 42. m is evaluated, but to no
effect.

-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk




More information about the Haskell-Cafe mailing list