[ATS can now be constrained in the class context stefanh@cse.unsw.edu.au**20060217173250] { adddir ./tests/constrained-assoc-types adddir ./tests/constrained-assoc-types/should_pass hunk ./Phrac/KindInference.hs 339 - mapM kiClassConstraints (map class_constraints classes) hunk ./Phrac/KindInference.hs 341 + mapM kiClassConstraints (map class_constraints classes) hunk ./Phrac/Map.hs 168 + hunk ./Phrac/WellFormedness.hs 124 - then phasefail ("no instance for superclass " ++ showPpr cid ++ - " found when checking instance declaration " ++ + then phasefail ("cannot entail " ++ showPpr' cc ++ + " when checking instance declaration " ++ hunk ./Phrac/WellFormedness.hs 170 - else - phasefail ("illegal context for class " ++ showPpr id ++ - ": only type variables can be constrained") + else return () +{- + phasefail ("illegal context for class " ++ showPpr id ++ + ": only type variables can be constrained") +-} addfile ./tests/constrained-assoc-types/should_pass/000.out hunk ./tests/constrained-assoc-types/should_pass/000.out 1 +"1" addfile ./tests/constrained-assoc-types/should_pass/000.phc hunk ./tests/constrained-assoc-types/should_pass/000.phc 1 +class Show (T a) => C a where { + type T a; + get :: a -> T a; +} + +data D = D; + +instance Show D where { + show _ = "D"; +} + +instance C D where { + type T D = D; + get _ = D; +} + +instance C Int where { + type T Int = Int; + get i = i; +} + +instance C a => C (List a) where { + type T (List a) = T a; + get l = case l of + Nil -> error "list empty"; + Cons x _ -> get x; + ; +} + +data E = E; + +instance C E where { + type T E = Int; + get _ = 42; +} + +test1 = show (get D); +test2 = show (get (Cons 1 (Cons 2 Nil))); +test3 = show (get E); +main = test2; + }