1
1
mirror of https://github.com/github/semantic.git synced 2024-12-20 05:11:44 +03:00

Generalize parsePythonPackage over the term type.

This commit is contained in:
Rob Rix 2019-10-18 13:56:32 -04:00
parent 7b9b1ecd2e
commit 95abbb3ce1
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -57,7 +57,6 @@ import Data.Graph.ControlFlowVertex (VertexDeclaration)
import Data.Language as Language import Data.Language as Language
import Data.List (isPrefixOf, isSuffixOf) import Data.List (isPrefixOf, isSuffixOf)
import Data.Project import Data.Project
import Data.Term
import Data.Text (pack, unpack) import Data.Text (pack, unpack)
import Language.Haskell.HsColour import Language.Haskell.HsColour
import Language.Haskell.HsColour.Colourise import Language.Haskell.HsColour.Colourise
@ -273,26 +272,28 @@ parseModules parser p = distributeFor (projectBlobs p) (parseModule p parser)
-- | Parse a list of packages from a python project. -- | Parse a list of packages from a python project.
parsePythonPackage :: forall syntax sig m . parsePythonPackage :: forall term sig m .
( Declarations1 syntax ( Declarations term
, Evaluatable syntax , Evaluatable (Base term)
, FreeVariables1 syntax , FreeVariables term
, AccessControls1 syntax , AccessControls term
, Functor syntax , Recursive term
, Member Distribute sig , Member Distribute sig
, Member Parse sig , Member Parse sig
, Member Resolution sig , Member Resolution sig
, Member Trace sig , Member Trace sig
, HasSpan term
, Show term
, Carrier sig m , Carrier sig m
, Effect sig , Effect sig
) )
=> Parser (Term syntax Loc) -- ^ A parser. => Parser term -- ^ A parser.
-> Project -- ^ Project to parse into a package. -> Project -- ^ Project to parse into a package.
-> m (Package (Term syntax Loc)) -> m (Package term)
parsePythonPackage parser project = do parsePythonPackage parser project = do
let runAnalysis = runEvaluator @_ @_ @(Value (Term syntax Loc) (Hole (Maybe Name) Precise)) let runAnalysis = runEvaluator @_ @_ @(Value term (Hole (Maybe Name) Precise))
. raiseHandler (runState PythonPackage.Unknown) . raiseHandler (runState PythonPackage.Unknown)
. raiseHandler (runState (lowerBound @(Heap (Hole (Maybe Name) Precise) (Hole (Maybe Name) Precise) (Value (Term syntax Loc) (Hole (Maybe Name) Precise))))) . raiseHandler (runState (lowerBound @(Heap (Hole (Maybe Name) Precise) (Hole (Maybe Name) Precise) (Value term (Hole (Maybe Name) Precise)))))
. raiseHandler runFresh . raiseHandler runFresh
. resumingLoadError . resumingLoadError
. resumingUnspecialized . resumingUnspecialized