T4361.hs 1.03 KB
Newer Older
1
{-# OPTIONS_GHC -Wno-redundant-constraints -Wno-simplifiable-class-constraints #-}
2 3 4 5 6 7 8 9 10 11
{-# LANGUAGE FlexibleContexts #-}

-- This test comes from Sergei Mechveliani's DoCon system

module Pol3_ (moduloBasisx) where

class CommutativeRing a
class CommutativeRing a => LinSolvRing a
class LinSolvRing a => EuclideanRing a

thomie's avatar
thomie committed
12
instance EuclideanRing a => LinSolvRing (Pol a)        -- XXXX
13 14 15 16 17 18 19 20
instance CommutativeRing a => CommutativeRing (Pol a)

data Pol a = MkPol

upLinSolvRing :: LinSolvRing a => a -> ()
upLinSolvRing = undefined

moduloBasisx :: (LinSolvRing (Pol a), CommutativeRing a) => Pol a -> ()
21 22
moduloBasisx p = let x :: ()
                     x = upLinSolvRing p
23 24
                 in ()

25
  -- This is very delicate!  The constraint (LinSolvRing (Pol a))
26
  -- arises in the RHS of x, and we must be careful *not* to simplify
27
  -- it with the instance declaration "XXXX", else we get the
28 29 30 31
  -- unsatisfiable constraint (EuclideanRing a). In effect, the
  -- given constraint in the type sig for moduleBasisx overlaps
  -- with the top level declaration.