Difference between revisions of "DDC/EffectSystem"

From HaskellWiki
< DDC
Jump to navigation Jump to search
Line 9: Line 9:
 
</haskell>
 
</haskell>
   
but if we need to use an effectful function defined in terms of a state monad, we must use the monadic version, <haskell>mapM instead.
+
but if we need to use an effectful function defined in terms of a state monad, we must use the monadic version, <hask>mapM</hask> instead.
   
 
<haskell>
 
<haskell>

Revision as of 00:46, 19 March 2008

Effect typing

Instead of state monads (like IO), Disciple uses default strict evaluation and effect typing to deal with computational effects.

The main benefit of effect typing over state monads is that the types of functions that cause effects have the same shape as their 'pure' counterparts, which lets us re-use more code.

for example, in Haskell the 'pure' map function has type:

    map :: (a -> b) -> [a] -> [b]

but if we need to use an effectful function defined in terms of a state monad, we must use the monadic version, mapM instead.

    mapM :: Monad m => (a -> m b) -> [a] -> m [b]