1
1
mirror of https://github.com/github/semantic.git synced 2024-12-19 12:51:52 +03:00

AbstractValue no longer requires the term type parameter.

This commit is contained in:
Rob Rix 2018-05-08 10:21:42 -04:00
parent eacb5b47d7
commit 5343047d2f
7 changed files with 15 additions and 15 deletions

View File

@ -40,7 +40,7 @@ class AbstractHole value where
-- | A 'Monad' abstracting the evaluation of (and under) binding constructs (functions, methods, etc).
--
-- This allows us to abstract the choice of whether to evaluate under binders for different value types.
class Show value => AbstractValue location term value effects where
class Show value => AbstractValue location value effects where
-- | Construct an abstract unit value.
-- TODO: This might be the same as the empty tuple for some value types
unit :: Evaluator location term value effects value
@ -149,7 +149,7 @@ class Show value => AbstractValue location term value effects where
-- | Attempt to extract a 'Prelude.Bool' from a given value.
forLoop :: ( AbstractValue location term value effects
forLoop :: ( AbstractValue location value effects
, Member (State (Environment location value)) effects
)
=> Evaluator location term value effects value -- ^ Initial statement
@ -161,7 +161,7 @@ forLoop initial cond step body =
localize (initial *> while cond (body *> step))
-- | The fundamental looping primitive, built on top of ifthenelse.
while :: AbstractValue location term value effects
while :: AbstractValue location value effects
=> Evaluator location term value effects value
-> Evaluator location term value effects value
-> Evaluator location term value effects value
@ -170,7 +170,7 @@ while cond body = loop $ \ continue -> do
ifthenelse this (body *> continue) unit
-- | Do-while loop, built on top of while.
doWhile :: AbstractValue location term value effects
doWhile :: AbstractValue location value effects
=> Evaluator location term value effects value
-> Evaluator location term value effects value
-> Evaluator location term value effects value
@ -178,7 +178,7 @@ doWhile body cond = loop $ \ continue -> body *> do
this <- cond
ifthenelse this continue unit
makeNamespace :: ( AbstractValue location term value effects
makeNamespace :: ( AbstractValue location value effects
, Member (State (Environment location value)) effects
, Member (State (Heap location value)) effects
, Ord location

View File

@ -47,7 +47,7 @@ class Evaluatable constr where
eval expr = throwResumable (Unspecialized ("Eval unspecialized for " ++ liftShowsPrec (const (const id)) (const id) 0 expr ""))
type EvaluatableConstraints location term value effects =
( AbstractValue location term value effects
( AbstractValue location value effects
, Addressable location effects
, Declarations term
, FreeVariables term
@ -93,7 +93,7 @@ runEvalErrorWith = runResumableWith
-- | Evaluate a term within the context of the scoped environment of 'scopedEnvTerm'.
-- Throws an 'EnvironmentLookupError' if @scopedEnvTerm@ does not have an environment.
evaluateInScopedEnv :: ( AbstractValue location term value effects
evaluateInScopedEnv :: ( AbstractValue location value effects
, Members '[ Resumable (EvalError value)
, State (Environment location value)
] effects

View File

@ -91,7 +91,7 @@ instance ( Addressable location effects
] effects
, Reducer (Type location) (Cell location (Type location))
)
=> AbstractValue location term (Type location) effects where
=> AbstractValue location (Type location) effects where
lambda names (Subterm _ body) = do
(env, tvars) <- foldr (\ name rest -> do
a <- alloc name

View File

@ -221,7 +221,7 @@ instance ( Addressable location (Goto effects (Value location) ': effects)
, Reducer (Value location) (Cell location (Value location))
, Show location
)
=> AbstractValue location term (Value location) (Goto effects (Value location) ': effects) where
=> AbstractValue location (Value location) (Goto effects (Value location) ': effects) where
unit = pure . injValue $ Unit
integer = pure . injValue . Integer . Number.Integer
boolean = pure . injValue . Boolean
@ -309,7 +309,7 @@ instance ( Addressable location (Goto effects (Value location) ': effects)
tentative x i j = attemptUnsafeArithmetic (x i j)
-- Dispatch whatever's contained inside a 'Number.SomeNumber' to its appropriate 'MonadValue' ctor
specialize :: (AbstractValue location term (Value location) effects, Member (Resumable (ValueError location)) effects) => Either ArithException Number.SomeNumber -> Evaluator location term (Value location) effects (Value location)
specialize :: (AbstractValue location (Value location) effects, Member (Resumable (ValueError location)) effects) => Either ArithException Number.SomeNumber -> Evaluator location term (Value location) effects (Value location)
specialize (Left exc) = throwValueError (ArithmeticError exc)
specialize (Right (Number.SomeNumber (Number.Integer i))) = integer i
specialize (Right (Number.SomeNumber (Number.Ratio r))) = rational r
@ -328,7 +328,7 @@ instance ( Addressable location (Goto effects (Value location) ': effects)
where
-- Explicit type signature is necessary here because we're passing all sorts of things
-- to these comparison functions.
go :: (AbstractValue location term (Value location) effects, Ord a) => a -> a -> Evaluator location term (Value location) effects (Value location)
go :: (AbstractValue location (Value location) effects, Ord a) => a -> a -> Evaluator location term (Value location) effects (Value location)
go l r = case comparator of
Concrete f -> boolean (f l r)
Generalized -> integer (orderingToInt (compare l r))

View File

@ -46,7 +46,7 @@ resolvePHPName n = do
where name = toName n
toName = BC.unpack . dropRelativePrefix . stripQuotes
include :: ( AbstractValue location term value effects
include :: ( AbstractValue location value effects
, Members '[ Reader (ModuleTable [Module term])
, Resumable ResolutionError
, State (Environment location value)

View File

@ -72,7 +72,7 @@ instance Evaluatable Require where
modifyEnv (`mergeNewer` importedEnv)
pure v -- Returns True if the file was loaded, False if it was already loaded. http://ruby-doc.org/core-2.5.0/Kernel.html#method-i-require
doRequire :: ( AbstractValue location term value effects
doRequire :: ( AbstractValue location value effects
, Members '[ EvalModule term value
, Reader LoadStack
, Reader (ModuleTable [M.Module term])
@ -109,7 +109,7 @@ instance Evaluatable Load where
doLoad path shouldWrap
eval (Load _) = raise (fail "invalid argument supplied to load, path is required")
doLoad :: ( AbstractValue location term value effects
doLoad :: ( AbstractValue location value effects
, Members '[ EvalModule term value
, Reader LoadStack
, Reader (ModuleTable [M.Module term])

View File

@ -115,7 +115,7 @@ typescriptExtensions = ["ts", "tsx", "d.ts"]
javascriptExtensions :: [String]
javascriptExtensions = ["js"]
evalRequire :: ( AbstractValue location term value effects
evalRequire :: ( AbstractValue location value effects
, Addressable location effects
, Members '[ EvalModule term value
, Reader (Environment location value)