I recently started exploring the core Hackage libraries, and there’s a repeating idiom that I don’t understand. Here is an example from the ST module :
instance Monad (ST s) where {-# INLINE (>>=) #-} (>>) = (*>) (ST m) >>= k = ST (\ s -> case (ms) of { (# new_s, r #) -> case (kr) of { ST k2 -> (k2 new_s) }})
In particular, I do not understand (# new_s, r #) . I assume that the second hash refers to an unreasonable value, but the rest is a mystery to me (something related to the "new state", presumably).
haskell st-monad
planarian
source share