[Haskell-cafe] Problem with tuple with one element constrained

Sergiu Ivanov sivanov at colimite.fr
Tue Apr 18 21:01:21 UTC 2017


Hello Tyson,

Thus quoth  Tyson Whitehead  at 19:41 on Tue, Apr 18 2017:
>
> I've been unable to get the following (simplified) code to be accepted
> by GHCi (8.0.1 and 8.0.2)
>
> Prelude> let (x, y) = (1, return 2)
[...]
> and I don't seem to be able to provide a type signatures that GHCi is
> okay with

GHCi handles polymorphic types of interactive expressions somewhat
differently from the polymorphic types of expressions loaded from
files. (I'd be happy if someone could reproduce the explanation which I
saw a couple times but which I cannot find any more.)


Anyway, I put the following in tuple.hs:

func :: Monad m => (Int, m Int)
func = (1, return 2)

Then, ghci tuple.hs swallows the file no problem and allows me to do

*Main> func :: (Int, Maybe Int)
(1, Just 2)


(I have GHCi 8.0.2.)

--
Sergiu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170418/bef0b8be/attachment-0001.sig>


More information about the Haskell-Cafe mailing list