[Haskell-beginners] Grappling with State Monad get

Theodore Lief Gannon tanuki at gmail.com
Tue Aug 1 23:35:14 UTC 2017

's' here is not a type variable, it's an actual variable. \s -> (s, s)
defines a lambda function which takes any value, and returns a tuple with
that value in both positions.

So yes, get is point-free, but the missing argument is right there in-line.
And yes, its type is simply implied from context.

On Aug 1, 2017 4:17 PM, "Olumide" <50295 at web.de> wrote:

Ahoy Haskellers,

In the section "Getting and Setting State" (http://learnyouahaskell.com/f
or-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?


- Olumide
Beginners mailing list
Beginners at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170801/6484bcbb/attachment-0001.html>

More information about the Beginners mailing list