
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) <interactive>:1:5: error: • Could not deduce (Monad m0) from the context: Num t bound by the inferred type for ‘x’: Num t => t at <interactive>:1:5-24 The type variable ‘m0’ is ambiguous • When checking that the inferred type x :: forall a (m :: * -> *) t. (Num a, Num t, Monad m) => t is as general as its inferred signature x :: forall t. Num t => t and I don't seem to be able to provide a type signatures that GHCi is okay with Prelude> let { x :: Int; y :: Monad m => m Int; (x, y) = (1, return 2) } <interactive>:5:40: error: • Ambiguous type variable ‘m0’ prevents the constraint ‘(Monad m0)’ from being solved. • When checking that the inferred type x :: forall a (m :: * -> *) t (m1 :: * -> *). (Num a, Num t, Monad m) => t is as general as its signature x :: Int Prelude> let (x, y) = (1, return 2) :: (Int, Monad m => m Int) <interactive>:4:31: error: • Illegal qualified type: Monad m => m Int GHC doesn't yet support impredicative polymorphism • In an expression type signature: (Int, Monad m => m Int) In the expression: (1, return 2) :: (Int, Monad m => m Int) In a pattern binding: (x, y) = (1, return 2) :: (Int, Monad m => m Int) Prelude> let (x,y) = (1,return 2) :: Monad m => (Int, m Int) <interactive>:7:5: error: • Ambiguous type variable ‘m0’ prevents the constraint ‘(Monad m0)’ from being solved. • When checking that the inferred type x :: forall (m :: * -> *). Monad m => Int is as general as its inferred signature x :: Int It seems the constraint on y leaks to x where it isn't well formed? Any help and/or explanations would be greatly appreciated. In my actual code the assignment is from the return value of a function so I can't just split it into two separate statements. Thanks! -Tyson