mirror of
https://github.com/github/semantic.git
synced 2024-12-30 02:14:20 +03:00
apply does not take Subterms.
This commit is contained in:
parent
25e95513ee
commit
b8fb250e10
@ -65,7 +65,7 @@ class (MonadAnalysis term value m, Show value) => MonadValue term value m where
|
|||||||
-- | Evaluate an abstraction (a binder like a lambda or method definition).
|
-- | Evaluate an abstraction (a binder like a lambda or method definition).
|
||||||
abstract :: [Name] -> Subterm term (m value) -> m value
|
abstract :: [Name] -> Subterm term (m value) -> m value
|
||||||
-- | Evaluate an application (like a function call).
|
-- | Evaluate an application (like a function call).
|
||||||
apply :: value -> [Subterm term (m value)] -> m value
|
apply :: value -> [m value] -> m value
|
||||||
|
|
||||||
-- | Attempt to extract a 'Prelude.Bool' from a given value.
|
-- | Attempt to extract a 'Prelude.Bool' from a given value.
|
||||||
toBool :: MonadValue term value m => value -> m Bool
|
toBool :: MonadValue term value m => value -> m Bool
|
||||||
@ -198,7 +198,7 @@ instance ( MonadAddressable location (Value location term) m
|
|||||||
apply op params = do
|
apply op params = do
|
||||||
Closure names body env <- maybe (fail ("expected a closure, got: " <> show op)) pure (prjValue op)
|
Closure names body env <- maybe (fail ("expected a closure, got: " <> show op)) pure (prjValue op)
|
||||||
bindings <- foldr (\ (name, param) rest -> do
|
bindings <- foldr (\ (name, param) rest -> do
|
||||||
v <- subtermValue param
|
v <- param
|
||||||
a <- alloc name
|
a <- alloc name
|
||||||
assign a v
|
assign a v
|
||||||
envInsert name a <$> rest) (pure env) (zip names params)
|
envInsert name a <$> rest) (pure env) (zip names params)
|
||||||
@ -245,6 +245,6 @@ instance (Alternative m, MonadAnalysis term Type m, MonadFresh m) => MonadValue
|
|||||||
|
|
||||||
apply op params = do
|
apply op params = do
|
||||||
tvar <- fresh
|
tvar <- fresh
|
||||||
paramTypes <- traverse subtermValue params
|
paramTypes <- sequenceA params
|
||||||
_ :-> ret <- op `unify` (Product paramTypes :-> Var tvar)
|
_ :-> ret <- op `unify` (Product paramTypes :-> Var tvar)
|
||||||
pure ret
|
pure ret
|
||||||
|
@ -18,7 +18,7 @@ instance Show1 Call where liftShowsPrec = genericLiftShowsPrec
|
|||||||
instance Evaluatable Call where
|
instance Evaluatable Call where
|
||||||
eval Call{..} = do
|
eval Call{..} = do
|
||||||
op <- subtermValue callFunction
|
op <- subtermValue callFunction
|
||||||
apply op callParams
|
apply op (map subtermValue callParams)
|
||||||
|
|
||||||
data Comparison a
|
data Comparison a
|
||||||
= LessThan !a !a
|
= LessThan !a !a
|
||||||
|
Loading…
Reference in New Issue
Block a user