Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell: How does MonadState's put work?

http://hackage.haskell.org/packages/archive/mtl/1.1.0.2/doc/html/src/Control-Monad-State-Lazy.html

instance (Monad m) => MonadState s (StateT s m) where
    get   = StateT $ \s -> return (s, s)
    put s = StateT $ \_ -> return ((), s)

What does the () do in the definition of put?

like image 375
SplinterOfChaos Avatar asked Jul 29 '26 20:07

SplinterOfChaos


1 Answers

The () is the return value of the action. Since put is used for its side effect (change state), it doesn't return anything useful.

like image 122
hzap Avatar answered Aug 01 '26 16:08

hzap