What type is chosen for a polymorphic expression when printed?

Viewed 149

What is the type of return "abc" when printed in ghci?

The point of the question is that it's polymorphic in the monad:

ghci> :t return "abc"
return "abc" :: (Monad m) => m [Char]

and what gets printed depends on which monad is chosen:

ghci> return "abc" :: Maybe String
Just "abc"

ghci> return "abc" :: [] String
["abc"]

but here's what's actually printed:

ghci> return "abc"
"abc"
2 Answers
Related