1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

Generalize scopeGraph over the term type.

This commit is contained in:
Rob Rix 2019-07-29 13:22:18 -04:00
parent 3bafa9a8b3
commit c7bee13fd4
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -15,7 +15,6 @@ import Control.Effect.Fresh
import Control.Effect.Reader
import Control.Effect.State
import Control.Monad ((>=>))
import qualified Data.Core as Core
import Data.File
import Data.Foldable (fold)
import Data.Function (fix)
@ -26,7 +25,6 @@ import Data.Name
import Data.Proxy
import qualified Data.Set as Set
import Data.Text (Text)
import Data.Term
import Prelude hiding (fail)
data Entry = Entry
@ -41,8 +39,17 @@ newtype ScopeGraph = ScopeGraph { unScopeGraph :: Map.Map Entry (Set.Set Entry)
instance Semigroup ScopeGraph where
ScopeGraph a <> ScopeGraph b = ScopeGraph (Map.unionWith (<>) a b)
scopeGraph :: [File (Term (Core.Ann :+: Core.Core) User)] -> (Heap User ScopeGraph, [File (Either (Loc, String) ScopeGraph)])
scopeGraph
:: Ord term
=> (forall sig m
. (Carrier sig m, Member (Reader Loc) sig, MonadFail m)
=> Analysis term User ScopeGraph m
-> (term -> m ScopeGraph)
-> (term -> m ScopeGraph)
)
-> [File term]
-> (Heap User ScopeGraph, [File (Either (Loc, String) ScopeGraph)])
scopeGraph eval
= run
. runFresh
. runHeap