diff options
author | Richard Eisenberg <rae@richarde.dev> | 2019-11-07 17:56:16 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-11-10 01:06:48 -0500 |
commit | 55ca10855713f3cc14b17f1b67f14c36dea4c651 (patch) | |
tree | 398764b7a0bdde6aa2e28ccb234b430b80a84109 /compiler/utils | |
parent | fa25c8c49464c3306b8c166fecc2bf5686d21996 (diff) | |
download | haskell-55ca10855713f3cc14b17f1b67f14c36dea4c651.tar.gz |
Fix #17405 by not checking imported equations
Previously, we checked all imported type family equations
for injectivity. This is very silly. Now, we check only
for conflicts.
Before I could even imagine doing the fix, I needed to untangle
several functions that were (in my opinion) overly complicated.
It's still not quite as perfect as I'd like, but it's good enough
for now.
Test case: typecheck/should_compile/T17405
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/Util.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/utils/Util.hs b/compiler/utils/Util.hs index c484ba90ea..e8d20e3208 100644 --- a/compiler/utils/Util.hs +++ b/compiler/utils/Util.hs @@ -49,6 +49,8 @@ module Util ( changeLast, + whenNonEmpty, + -- * Tuples fstOf3, sndOf3, thdOf3, firstM, first3M, secondM, @@ -137,6 +139,7 @@ import Data.Data import Data.IORef ( IORef, newIORef, atomicModifyIORef' ) import System.IO.Unsafe ( unsafePerformIO ) import Data.List hiding (group) +import Data.List.NonEmpty ( NonEmpty(..) ) import GHC.Exts import GHC.Stack (HasCallStack) @@ -610,6 +613,10 @@ changeLast [] _ = panic "changeLast" changeLast [_] x = [x] changeLast (x:xs) x' = x : changeLast xs x' +whenNonEmpty :: Applicative m => [a] -> (NonEmpty a -> m ()) -> m () +whenNonEmpty [] _ = pure () +whenNonEmpty (x:xs) f = f (x :| xs) + {- ************************************************************************ * * |