What is the type of return 5 in Haskell when no context is given?
问题 In this question the OP asks what the type of the expression return 5 is and the answer has already been given in that question: it is a generic type, as can be verified by typing :t return 5 in the Haskell interpreter: return 5 :: (Num a, Monad m) => m a The specific implementation of return is determined by the context in which it appears: type inference will restrict m to a specific monad such as Maybe , [] , IO , and so on. I can also force the interpreter to pick a specific monad by