Soon you are trying to build an Impredicative type that the GHC cannot do. You can do:
位 Control.Arrow > let (a,b) = (first, second) :: Arrow a => (abb -> a (b, b) (b, b), abb -> a (b, b) (b, b)) 位 Control.Arrow > :ta a :: Arrow a => abb -> a (b, b) (b, b) 位 Control.Arrow > :tb b :: Arrow a => abb -> a (b, b) (b, b)
or
:set -XImpredicativeTypes 位 Control.Arrow > let (a,b) = (first, second) :: (Arrow a => abb -> a (b, b) (b, b), Arrow a => abb -> a (b, b) (b, b)) 位 Control.Arrow > :ta a :: Arrow a => abb -> a (b, b) (b, b) 位 Control.Arrow > :tb b :: Arrow a => abb -> a (b, b) (b, b)
but you cannot do:
位 Control.Arrow > let (a,b) = (first, second) :: (Arrow a, Arrow a') => (abb -> a (b, b) (b, b), a' bb -> a' (b, b) (b, b))
To isolate the problem, this works:
位 Control.Arrow > let p = (first, second) :: (Arrow a, Arrow a') => (abb -> a (b, b) (b, b), a' bb -> a' (b, b) (b, b)); 位 Control.Arrow > :tp p :: (Arrow a', Arrow a) => (abb -> a (b, b) (b, b), a' bb -> a' (b, b) (b, b))
but when you try to associate this with a pattern:
位 Control.Arrow > let (a, b) = p
he fails. The restrictions are outside the type of pair and are redundant for the other half of the pair, since
位 Control.Arrow > :set -XImpredicativeTypes 位 Control.Arrow > let p = (first, second) :: (Arrow a => abb -> a (b, b) (b, b), Arrow a => abb -> a (b, b) (b, b)) 位 Control.Arrow > let (a, b) = p
work.
A simple example:
位 Prelude Data.Monoid > :t (mappend, ()) (mappend, ()) :: Monoid a => (a -> a -> a, ()) 位 Prelude Data.Monoid > let (a, b) = (mappend, ()) <interactive>:12:5: No instance for (Monoid a0) arising from the ambiguity check for 'b' The type variable 'a0' is ambiguous When checking that 'b' has the inferred type '()' Probable cause: the inferred type is ambiguous
Constraints need to be transferred, but type () does not have a , i.e. Monoid a => () is an ambiguous type.
Note: let (a,b) = ((+), (*)) seems to work. I have no idea why and how Num handled specifically:
位 Prelude Data.Monoid > let x = () :: Num a => () 位 Prelude Data.Monoid > :tx x :: () 位 Prelude Data.Monoid > let x = () :: Monoid m => () <interactive>:12:9: No instance for (Monoid m0) ...