mirror of
https://github.com/github/semantic.git
synced 2024-12-11 08:45:48 +03:00
Rename apply to call.
This commit is contained in:
parent
89e5183af0
commit
aa0ff616ab
@ -126,7 +126,7 @@ class (Monad m, Show value) => MonadValue location value m | m value -> location
|
||||
-- | Evaluate an abstraction (a binder like a lambda or method definition).
|
||||
abstract :: (FreeVariables term, MonadControl term m) => [Name] -> Subterm term (m value) -> m value
|
||||
-- | Evaluate an application (like a function call).
|
||||
apply :: value -> [m value] -> m value
|
||||
call :: value -> [m value] -> m value
|
||||
|
||||
-- | Primitive looping combinator, approximately equivalent to 'fix'. This should be used in place of direct recursion, as it allows abstraction over recursion.
|
||||
--
|
||||
|
@ -197,7 +197,7 @@ evaluatePackage p = pushPackage p (localModuleTable (<> packageModules p)
|
||||
(traverse evaluateEntryPoint (ModuleTable.toPairs (packageEntryPoints p))))
|
||||
where evaluateEntryPoint (m, sym) = do
|
||||
(_, v) <- require m
|
||||
maybe (pure v) ((`X.apply` []) <=< variable) sym
|
||||
maybe (pure v) ((`call` []) <=< variable) sym
|
||||
|
||||
pushPackage :: ( Effectful m
|
||||
, Member (Reader (SomeOrigin term)) effects
|
||||
|
@ -118,7 +118,7 @@ instance ( Alternative m
|
||||
(Int, Float) -> pure Int
|
||||
_ -> unify left right $> Bool
|
||||
|
||||
apply op params = do
|
||||
call op params = do
|
||||
tvar <- fresh
|
||||
paramTypes <- sequenceA params
|
||||
_ :-> ret <- op `unify` (Product paramTypes :-> Var tvar)
|
||||
|
@ -300,7 +300,7 @@ instance (Monad m, MonadEvaluatable location term (Value location) m) => MonadVa
|
||||
l <- label body
|
||||
injValue . Closure names l . Env.bind (foldr Set.delete (Set.fromList (freeVariables body)) names) <$> getEnv
|
||||
|
||||
apply op params = do
|
||||
call op params = do
|
||||
Closure names label env <- maybe (fail ("expected a closure, got: " <> show op)) pure (prjValue op)
|
||||
bindings <- foldr (\ (name, param) rest -> do
|
||||
v <- param
|
||||
|
@ -6,7 +6,7 @@ import Data.Abstract.Number (liftIntegralFrac, liftReal, liftedExponent)
|
||||
import Data.Fixed
|
||||
import Diffing.Algorithm
|
||||
import Prelude
|
||||
import Prologue hiding (apply)
|
||||
import Prologue
|
||||
|
||||
-- | Typical prefix function application, like `f(x)` in many languages, or `f x` in Haskell.
|
||||
data Call a = Call { callContext :: ![a], callFunction :: !a, callParams :: ![a], callBlock :: !a }
|
||||
@ -19,7 +19,7 @@ instance Show1 Call where liftShowsPrec = genericLiftShowsPrec
|
||||
instance Evaluatable Call where
|
||||
eval Call{..} = do
|
||||
op <- subtermValue callFunction
|
||||
apply op (map subtermValue callParams)
|
||||
call op (map subtermValue callParams)
|
||||
|
||||
data Comparison a
|
||||
= LessThan !a !a
|
||||
|
Loading…
Reference in New Issue
Block a user