[Haskell-cafe] Re: MonadFix

Joost Behrends webmaster at h-labahn.de
Thu Dec 20 21:40:31 EST 2007


Ryan Ingram <ryani.spam <at> gmail.com> writes:

> I just want to point out that this isn't true; "put" in the State monad
doesn't do any destructive update at all (unlike, for example, IORef).
>  
> newtype State s a = State { runState :: s -> (a,s) }
>  
> That is, your "divisions" function of type
>   divisions :: State DivIter DivIter
> is equivalent to the type
>   runState divisions :: DivIter -> (DivIter, DivIter)
> and the code is the same as if you'd just passed the DivIter directly along.
>  
>   -- ryan
> 
Oops ?

sry, i do not understand nothing.

The syntax with the block in 

"newtype State s a = State { runState :: s -> (a,s) }"

is not in the tutorials i read. And i do not understand 
" ... passed the DivIter directly along ". "Passed along" ?? 

But you'd probably better try not to explain this. Continued work in Haskell by
itself will let me understand that some weeks from now. 

Thanks, Joost






More information about the Haskell-Cafe mailing list