What is the type of <- in Haskell?

Gergely

I have a working program

main = do

  inpStr <- getLine
  putStrLn ( "Hello " ++ inpStr )

where

putStrLn :: String -> IO ()

and

getLine :: IO String  

From this can I conclude that the type of <- is

IO a -> a

?

Yuri Kovalenko

Unfortunately, it is not a regular function, but a language construct. You can use it only in do blocks to "extract" value from some context, such as IO.

do blocks and <- is just a syntax sugar for such things called Monads (and IO is one of them).

There are some other examples of such contexts, which you can use with do and <-, such as lists, optional, or nullable, values (such as Maybe Int), stateful computations and so on.

Some links:

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

What is the type of Nothing in Haskell?

What is the type keyword in Haskell

What is the IO type in Haskell

what is the type () :: () in haskell means?

Haskell function type not what expected

What is the type of (1 2) in Haskell?

Haskell-(Type declaration) what is "a"?

What is RealFloat type in Haskell used for?

What is the type of foldr map in haskell?

what is the difference between type "a" and type "t" in Haskell type signature?

What does the symbol `!` mean in type declarations in Haskell?

What does type signature for `undefined` mean in Haskell?

Haskell: What does it mean for a type signature to be total?

What's wrong with my Haskell type synonym?

What is the type of Haskell's bind function?

What does `Num a => a` mean in Haskell type system?

What is the purpose of including the type in its definition in haskell?

What is the meaning of parentheses in Haskell type signatures?

Haskell: What does type f a actually mean?

What does `... -> t a ->...` mean in type signature in Haskell?

What makes two type expressions in Haskell equivalent?

What is the default type evaluation of MonadPlus in Haskell?

What is the type of map.map in Haskell?

What is the type of (==) with only one argument in Haskell

What does something :: Wrapper type mean in Haskell?

What is the way to describe the type signature of Haskell functions that are not type-specific?

What is the type of the variable in do-notation here in Haskell?

What is the type of return 5 in Haskell when no context is given?

What does this function do in Haskell? I'm confused with the type