summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/T4361.hs
blob: 19727c2e5328251d8426dfa51db8ebe2730b49e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{-# 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

instance EuclideanRing a => LinSolvRing (Pol a)	       -- XXXX
instance CommutativeRing a => CommutativeRing (Pol a)

data Pol a = MkPol

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

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

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