Tariq on Nostr: The #haskell mooc I'm doing is introducing IO but imho not very well. I'm confused by ...
The #haskell mooc I'm doing is introducing IO but imho not very well.
I'm confused by the following snippet:
-------
ghci> val1 <- putStrLn "hello"
hello
ghci> val1
()
ghci> val2 = putStrLn "bye"
ghci> val2
bye
-----
val2 is easy I think. val2 is putStrLn "bye" and when prompted to represent itself the output is "bye", I guess the IO is "executed".
but val1 I don't get.
what is <- and why does it produce and output on the repl? and what is () ?
Published at
2025-04-15 14:31:07Event JSON
{
"id": "761bf12b31df5a210af4a8fb046b95c68050b1efed254837ff7cd3f409760e79",
"pubkey": "340694a5c7115fe0918fe7ec9038786592e3804f1a0e457e3e09d03ecfdadc6b",
"created_at": 1744727467,
"kind": 1,
"tags": [
[
"t",
"haskell"
],
[
"proxy",
"https://mastodon.social/users/rzeta0/statuses/114342459322248766",
"activitypub"
],
[
"client",
"Mostr",
"31990:6be38f8c63df7dbf84db7ec4a6e6fbbd8d19dca3b980efad18585c46f04b26f9:mostr",
"wss://relay.mostr.pub"
]
],
"content": "The #haskell mooc I'm doing is introducing IO but imho not very well.\n\nI'm confused by the following snippet:\n\n-------\n\nghci\u003e val1 \u003c- putStrLn \"hello\"\nhello\n\nghci\u003e val1\n()\n\nghci\u003e val2 = putStrLn \"bye\"\n\nghci\u003e val2\nbye\n\n-----\n\nval2 is easy I think. val2 is putStrLn \"bye\" and when prompted to represent itself the output is \"bye\", I guess the IO is \"executed\".\n\nbut val1 I don't get.\n\nwhat is \u003c- and why does it produce and output on the repl? and what is () ?",
"sig": "b5198d862e981f5c550a54d5ee652721d8011cf968313d01a9d9cc273bd4ae3dcc632840a29dee5abc0a212274ed9d218b44ea056460b958d3ce972f13d641fb"
}