[Haskell-beginners] Grappling with State Monad get

Olumide 50295 at web.de
Tue Aug 1 23:16:04 UTC 2017


Ahoy Haskellers,

In the section "Getting and Setting State" 
(http://learnyouahaskell.com/for-a-few-monads-more#state) in LYH get is 
defined as

get = state $ \s -> (s, s)

How does does get determine the type s, is considering that it has no 
argument as per the definition given above? Or is the definition written 
in some sort of point-free notation where an argument has been dropped?

I find the line stackNow <- get in the the function(?) stackyStack 
confusing for the same reason. I guess my difficulty is that state $ \s 
->(s , s) has a generic type (s) whereas the stackyStack has a concrete 
type. Is the type of s determined from the type of the stateful 
computation/do notation?

Regards,

- Olumide


More information about the Beginners mailing list