[Haskell-cafe] Problem with tuple with one element constrained
twhitehead at gmail.com
Thu Apr 20 02:11:42 UTC 2017
On Tue, Apr 18, 2017, 16:02 Joshua Grosso <jgrosso1 at asu.edu <mailto:jgrosso1 at asu.edu>> wrote:
/If/ I'm understanding correctly, GHCI's complaining about the fact that `return 2` requires it to create an instance of a `Monad`, but it doesn't know which `Monad` instance it should use...
Does `let (x, y) = (1, return 2) :: (Int, Maybe Int)` work (where you can replace `Maybe` with any other monad)?
Thanks for the input. You are correct that if I choose a particular Monad instance GHCi accepts the code.
I believe it should be able to do the assignment without choosing one though. It is, for example, okay with let y = return 2.
I'm thinking Sergiu is onto something about this having to do with special GHCi handling.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe