mirror of
https://github.com/github/semantic.git
synced 2024-11-27 12:57:49 +03:00
move multiple into AbstractValue and rename to tuple
This commit is contained in:
parent
9e936a4a1a
commit
36b5ac8aa9
@ -73,9 +73,6 @@ class Show value => AbstractIntro value where
|
||||
-- | Construct a rational value.
|
||||
rational :: Rational -> value
|
||||
|
||||
-- | Construct an N-ary tuple of multiple (possibly-disjoint) values
|
||||
multiple :: [value] -> value
|
||||
|
||||
-- | Construct a key-value pair for use in a hash.
|
||||
kvPair :: value -> value -> value
|
||||
|
||||
@ -114,6 +111,9 @@ class (AbstractFunction address value effects, AbstractIntro value) => AbstractV
|
||||
liftBitwise2 :: (forall a . (Integral a, Bits a) => a -> a -> a)
|
||||
-> (value -> value -> Evaluator address value effects value)
|
||||
|
||||
-- | Construct an N-ary tuple of multiple (possibly-disjoint) values
|
||||
tuple :: [value] -> Evaluator address value effects value
|
||||
|
||||
-- | Construct an array of zero or more values.
|
||||
array :: [value] -> Evaluator address value effects value
|
||||
|
||||
|
@ -108,7 +108,6 @@ instance AbstractIntro Type where
|
||||
float _ = Float
|
||||
symbol _ = Symbol
|
||||
rational _ = Rational
|
||||
multiple = zeroOrMoreProduct
|
||||
hash = Hash
|
||||
kvPair k v = k :* v
|
||||
|
||||
@ -153,6 +152,8 @@ instance ( Member (Allocator address Type) effects
|
||||
var <- fresh
|
||||
Array <$> foldr (\ t1 -> (unify t1 =<<)) (pure (Var var)) fields
|
||||
|
||||
tuple = pure . zeroOrMoreProduct
|
||||
|
||||
klass _ _ _ = pure Object
|
||||
namespace _ _ = pure Unit
|
||||
|
||||
|
@ -92,8 +92,6 @@ instance Show address => AbstractIntro (Value address body) where
|
||||
symbol = Symbol
|
||||
rational = Rational . Number.Ratio
|
||||
|
||||
multiple = Tuple
|
||||
|
||||
kvPair = KVPair
|
||||
hash = Hash . map (uncurry KVPair)
|
||||
|
||||
@ -117,7 +115,8 @@ instance ( Coercible body (Eff effects)
|
||||
| KVPair k v <- val = pure (k, v)
|
||||
| otherwise = throwValueError $ KeyValueError val
|
||||
|
||||
array = pure . Array
|
||||
tuple = pure . Tuple
|
||||
array = pure . Array
|
||||
|
||||
klass n [] env = pure $ Class n env
|
||||
klass n supers env = do
|
||||
|
@ -101,7 +101,7 @@ instance Show1 VariableDeclaration where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
instance Evaluatable VariableDeclaration where
|
||||
eval (VariableDeclaration []) = rvalBox unit
|
||||
eval (VariableDeclaration decs) = rvalBox =<< (multiple <$> traverse subtermValue decs)
|
||||
eval (VariableDeclaration decs) = rvalBox =<< tuple =<< traverse subtermValue decs
|
||||
|
||||
instance Declarations a => Declarations (VariableDeclaration a) where
|
||||
declaredName (VariableDeclaration vars) = case vars of
|
||||
|
@ -200,7 +200,7 @@ instance Ord1 Tuple where liftCompare = genericLiftCompare
|
||||
instance Show1 Tuple where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
instance Evaluatable Tuple where
|
||||
eval (Tuple cs) = rvalBox =<< (multiple <$> traverse subtermValue cs)
|
||||
eval (Tuple cs) = rvalBox =<< tuple =<< traverse subtermValue cs
|
||||
|
||||
newtype Set a = Set { setElements :: [a] }
|
||||
deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable)
|
||||
|
Loading…
Reference in New Issue
Block a user