flexible contexts and context reduction

Ross Paterson ross at soi.city.ac.uk
Wed Mar 26 17:07:18 EDT 2008


On Wed, Mar 26, 2008 at 08:52:43PM +0000, Ganesh Sittampalam wrote:
> I'm a bit confused about why the following program doesn't compile (in 
> any of 6.6.1, 6.8.1 and 6.9.20080316). Shouldn't the Ord (a, b) context 
> be reduced?
>
> {-# LANGUAGE FlexibleContexts #-}
>
> module Test2 where
>
> foo :: Ord (a, b) => (a, b) -> (a, b)
> foo = bar
>
> bar :: (Ord a, Ord b) => (a, b) -> (a, b)
> bar = id

To use bar, you need (Ord a, Ord b).  You're assuming that Ord (a, b)
implies that, but it's the other way round.


More information about the Glasgow-haskell-users mailing list