diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2016-10-22 15:40:51 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-10-22 15:40:54 -0400 |
commit | 6e9a51c06642d01b52a35d1e6a29c9aa5798f1e8 (patch) | |
tree | beef854da7bd0e0e2b12aef42b94ec0e9f74ac83 /compiler/backpack | |
parent | 3cb32d8b0b51c548ab424139c66cce6b37a2ab1b (diff) | |
download | haskell-6e9a51c06642d01b52a35d1e6a29c9aa5798f1e8.tar.gz |
Refactoring: Delete copied function in backpack/NameShape
Also moved a few utility functions which work with Avails into
the Avail module to avoid import loops and increase discoverability.
Reviewers: austin, bgamari, ezyang
Reviewed By: ezyang
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2629
Diffstat (limited to 'compiler/backpack')
-rw-r--r-- | compiler/backpack/NameShape.hs | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/compiler/backpack/NameShape.hs b/compiler/backpack/NameShape.hs index 0a2d7ca319..da1b5ea4fe 100644 --- a/compiler/backpack/NameShape.hs +++ b/compiler/backpack/NameShape.hs @@ -22,9 +22,10 @@ import Name import NameEnv import TcRnMonad import Util -import ListSetOps import IfaceEnv +import Avail ( plusAvail ) + import Control.Monad -- Note [NameShape] @@ -196,30 +197,6 @@ mergeAvails as1 as2 = let mkNE as = mkNameEnv [(availName a, a) | a <- as] in nameEnvElts (plusNameEnv_C plusAvail (mkNE as1) (mkNE as2)) --- | Join two 'AvailInfo's together. -plusAvail :: AvailInfo -> AvailInfo -> AvailInfo -plusAvail a1 a2 - | debugIsOn && availName a1 /= availName a2 - = pprPanic "RnEnv.plusAvail names differ" (hsep [ppr a1,ppr a2]) -plusAvail a1@(Avail {}) (Avail {}) = a1 -plusAvail (AvailTC _ [] []) a2@(AvailTC {}) = a2 -plusAvail a1@(AvailTC {}) (AvailTC _ [] []) = a1 -plusAvail (AvailTC n1 (s1:ss1) fs1) (AvailTC n2 (s2:ss2) fs2) - = case (n1==s1, n2==s2) of -- Maintain invariant the parent is first - (True,True) -> AvailTC n1 (s1 : (ss1 `unionLists` ss2)) - (fs1 `unionLists` fs2) - (True,False) -> AvailTC n1 (s1 : (ss1 `unionLists` (s2:ss2))) - (fs1 `unionLists` fs2) - (False,True) -> AvailTC n1 (s2 : ((s1:ss1) `unionLists` ss2)) - (fs1 `unionLists` fs2) - (False,False) -> AvailTC n1 ((s1:ss1) `unionLists` (s2:ss2)) - (fs1 `unionLists` fs2) -plusAvail (AvailTC n1 ss1 fs1) (AvailTC _ [] fs2) - = AvailTC n1 ss1 (fs1 `unionLists` fs2) -plusAvail (AvailTC n1 [] fs1) (AvailTC _ ss2 fs2) - = AvailTC n1 ss2 (fs1 `unionLists` fs2) -plusAvail a1 a2 = pprPanic "RnEnv.plusAvail" (hsep [ppr a1,ppr a2]) - {- ************************************************************************ * * |