diff options
author | Apoorv Ingle <apoorv-ingle@uiowa.edu> | 2023-02-06 09:13:10 -0600 |
---|---|---|
committer | sheaf <sam.derbyshire@gmail.com> | 2023-03-06 23:26:12 +0000 |
commit | c6432eacdac8e8fd135e52b2fb51bcb43b6913c3 (patch) | |
tree | 7e828ea71d138b4b94695e76250da93a22e94711 /testsuite/tests | |
parent | cad5c5760f6fe06057eb7ad9927b9c1e83417c1e (diff) | |
download | haskell-c6432eacdac8e8fd135e52b2fb51bcb43b6913c3.tar.gz |
Constraint simplification loop now depends on `ExpansionFuel`
instead of a boolean flag for `CDictCan.cc_pend_sc`.
Pending givens get a fuel of 3 while Wanted and quantified constraints get a fuel of 1.
This helps pending given constraints to keep up with pending wanted constraints in case of
`UndecidableSuperClasses` and superclass expansions while simplifying the infered type.
Adds 3 dynamic flags for controlling the fuels for each type of constraints
`-fgivens-expansion-fuel` for givens `-fwanteds-expansion-fuel` for wanteds and `-fqcs-expansion-fuel` for quantified constraints
Fixes #21909
Added Tests T21909, T21909b
Added Note [Expanding Recursive Superclasses and ExpansionFuel]
Diffstat (limited to 'testsuite/tests')
-rw-r--r-- | testsuite/tests/typecheck/should_compile/T21909.hs | 24 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/T21909b.hs | 12 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/all.T | 2 |
3 files changed, 38 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/T21909.hs b/testsuite/tests/typecheck/should_compile/T21909.hs new file mode 100644 index 0000000000..2485134703 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T21909.hs @@ -0,0 +1,24 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE UndecidableSuperClasses #-} + +module T21909 where + +import Data.Kind + +class (Monad m, MyMonad (Inner m)) => MyMonad m where + type Inner m :: Type -> Type + foo :: m Int + +works :: MyMonad m => m String +works = show <$> ((+ 1) <$> foo) + +fails :: MyMonad m => m String +fails = show <$> fooPlusOne + where + fooPlusOne = (+ 1) <$> foo + +alsoFails :: MyMonad m => m String +alsoFails = + let fooPlusOne = (+ 1) <$> foo + in show <$> fooPlusOne diff --git a/testsuite/tests/typecheck/should_compile/T21909b.hs b/testsuite/tests/typecheck/should_compile/T21909b.hs new file mode 100644 index 0000000000..3e02ae45f5 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T21909b.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE UndecidableSuperClasses, FunctionalDependencies, MultiParamTypeClasses, GADTs #-} + +module T21909b where + +class C [a] => C a where + foo :: a -> Int + +bar :: C a => a -> Int +bar x = foolocal x + where + foolocal a = foo a diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 2c6debc98f..327dd93675 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -864,3 +864,5 @@ test('T22924', normal, compile, ['']) test('T22985a', normal, compile, ['-O']) test('T22985b', normal, compile, ['']) test('T23018', normal, compile, ['']) +test('T21909', normal, compile, ['']) +test('T21909b', normal, compile, [''])
\ No newline at end of file |