Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
8016561f
by Simon Peyton Jones at 2025-07-08T07:41:13-04:00
-
454cd682
by Simon Peyton Jones at 2025-07-08T07:41:13-04:00
5 changed files:
- + testsuite/tests/indexed-types/should_fail/T26176.hs
- + testsuite/tests/indexed-types/should_fail/T26176.stderr
- testsuite/tests/indexed-types/should_fail/all.T
- + testsuite/tests/typecheck/should_compile/T14010.hs
- testsuite/tests/typecheck/should_compile/all.T
Changes:
1 | +{-# LANGUAGE DataKinds #-}
|
|
2 | +{-# LANGUAGE TypeFamilies #-}
|
|
3 | +module T26176 where
|
|
4 | + |
|
5 | +-- In a previous version of GHC this test led to
|
|
6 | +-- a very misleading error message
|
|
7 | + |
|
8 | +import GHC.TypeNats
|
|
9 | + |
|
10 | +data T = X
|
|
11 | +type family FA t where FA X = 1
|
|
12 | +type family FB t where FB X = 2
|
|
13 | + |
|
14 | +foo :: forall p (t :: T). p t
|
|
15 | +foo = undefined
|
|
16 | + where
|
|
17 | + a :: SNat 5
|
|
18 | + a = b
|
|
19 | + |
|
20 | + b :: SNat (FA t)
|
|
21 | + b = undefined
|
|
22 | + |
|
23 | + c :: SNat 3
|
|
24 | + c = d
|
|
25 | + |
|
26 | + d :: SNat (FB t)
|
|
27 | + d = undefined
|
|
28 | + |
|
29 | + x = bar @t
|
|
30 | + |
|
31 | +bar :: FA t <= FB t => p t
|
|
32 | +bar = undefined |
1 | +T26176.hs:18:7: error: [GHC-83865]
|
|
2 | + • Couldn't match type ‘FA t’ with ‘5’
|
|
3 | + Expected: SNat 5
|
|
4 | + Actual: SNat (FA t)
|
|
5 | + • In the expression: b
|
|
6 | + In an equation for ‘a’: a = b
|
|
7 | + In an equation for ‘foo’:
|
|
8 | + foo
|
|
9 | + = undefined
|
|
10 | + where
|
|
11 | + a :: SNat 5
|
|
12 | + a = b
|
|
13 | + b :: SNat (FA t)
|
|
14 | + b = undefined
|
|
15 | + ....
|
|
16 | + • Relevant bindings include
|
|
17 | + b :: SNat (FA t) (bound at T26176.hs:21:3)
|
|
18 | + d :: SNat (FB t) (bound at T26176.hs:27:3)
|
|
19 | + x :: p0 t (bound at T26176.hs:29:3)
|
|
20 | + foo :: p t (bound at T26176.hs:15:1)
|
|
21 | + |
|
22 | +T26176.hs:24:7: error: [GHC-83865]
|
|
23 | + • Couldn't match type ‘FB t’ with ‘3’
|
|
24 | + Expected: SNat 3
|
|
25 | + Actual: SNat (FB t)
|
|
26 | + • In the expression: d
|
|
27 | + In an equation for ‘c’: c = d
|
|
28 | + In an equation for ‘foo’:
|
|
29 | + foo
|
|
30 | + = undefined
|
|
31 | + where
|
|
32 | + a :: SNat 5
|
|
33 | + a = b
|
|
34 | + b :: SNat (FA t)
|
|
35 | + b = undefined
|
|
36 | + ....
|
|
37 | + • Relevant bindings include
|
|
38 | + d :: SNat (FB t) (bound at T26176.hs:27:3)
|
|
39 | + x :: p0 t (bound at T26176.hs:29:3)
|
|
40 | + foo :: p t (bound at T26176.hs:15:1)
|
|
41 | + |
... | ... | @@ -172,3 +172,4 @@ test('T21896', normal, compile_fail, ['']) |
172 | 172 | test('HsBootFam', [extra_files(['HsBootFam_aux.hs','HsBootFam_aux.hs-boot'])], multimod_compile_fail, ['HsBootFam', ''])
|
173 | 173 | test('BadFamInstDecl', [extra_files(['BadFamInstDecl_aux.hs'])], multimod_compile_fail, ['BadFamInstDecl', ''])
|
174 | 174 | test('T19773', [], multimod_compile_fail, ['T19773', '-Wall'])
|
175 | +test('T26176', normal, compile_fail, ['']) |
1 | +{-# LANGUAGE NoImplicitPrelude, PolyKinds, DataKinds, TypeFamilies,
|
|
2 | + UndecidableSuperClasses, RankNTypes, TypeOperators,
|
|
3 | + FlexibleContexts, TypeSynonymInstances, FlexibleInstances,
|
|
4 | + UndecidableInstances #-}
|
|
5 | +module Monolith where
|
|
6 | + |
|
7 | +import Data.Kind (Type)
|
|
8 | +import GHC.Exts (Constraint)
|
|
9 | + |
|
10 | +type family (~>) :: c -> c -> Type
|
|
11 | + |
|
12 | +type instance (~>) = (->)
|
|
13 | +type instance (~>) = ArrPair
|
|
14 | + |
|
15 | +type family Fst (p :: (a, b)) :: a where
|
|
16 | + Fst '(x, _) = x
|
|
17 | + |
|
18 | +type family Snd (p :: (a, b)) :: b where
|
|
19 | + Snd '(_, y) = y
|
|
20 | + |
|
21 | +data ArrPair a b = ArrPair (Fst a ~> Fst b) (Snd a ~> Snd b)
|
|
22 | + |
|
23 | +type family Super c :: Constraint where
|
|
24 | + Super Type = ()
|
|
25 | + Super (c, d) = (Category c, Category d)
|
|
26 | + |
|
27 | +class Super cat => Category cat where
|
|
28 | + id :: forall (a :: cat). a ~> a
|
|
29 | + |
|
30 | +instance Category Type where
|
|
31 | + id = \x -> x
|
|
32 | + |
|
33 | +instance (Category c, Category d) => Category (c, d) where
|
|
34 | + id = ArrPair id id
|
|
35 | + |
|
36 | +-- The commented out version worked
|
|
37 | +-- class Category (c, d) => Functor (f :: c -> d) where
|
|
38 | +class (Category c, Category d) => Functor (f :: c -> d) where
|
|
39 | + map :: (a ~> b) -> (f a ~> f b)
|
|
40 | + |
|
41 | +data OnSnd f a b = OnSnd (f '(a, b))
|
|
42 | + |
|
43 | +instance Functor (f :: (c, d) -> Type) => Functor (OnSnd f a) where
|
|
44 | + map f (OnSnd x) = OnSnd (map (ArrPair id f) x) |
... | ... | @@ -939,3 +939,4 @@ test('T25960', normal, compile, ['']) |
939 | 939 | test('T26020', normal, compile, [''])
|
940 | 940 | test('T26020a', [extra_files(['T26020a_help.hs'])], multimod_compile, ['T26020a', '-v0'])
|
941 | 941 | test('T25992', normal, compile, [''])
|
942 | +test('T14010', normal, compile, ['']) |