[Haskell-cafe] Problem with tuple with one element constrained
Tyson Whitehead
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)?
Hi Joshua,
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.
Thanks! -Tyson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170419/bb8dacc8/attachment-0001.html>
More information about the Haskell-Cafe
mailing list