module Language.Sifflet.Expr
(
ArgSpec(..)
, aspecsLookup
, EvalResult, EvalRes(EvalOk, EvalError, EvalUntried)
, exprToValue, valueToLiteral, valueToLiteral'
, Symbol(..)
, OStr, OBool, OChar
, Expr(..), eSymbol, eSym, eInt, eString, eChar, eFloat
, toLambdaExpr
, callToApp, mapply
, appToCall, mcall
, exprIsAtomic
, exprIsCompound
, eBool, eFalse, eTrue, eIf
, eList, eCall
, exprIsLiteral
, exprSymbols, exprVarNames
, Operator(..)
, Precedence
, OperatorGrouping(..)
, Value(..), valueFunction
, Functions(..)
, Function(..), functionName, functionNArgs
, functionArgSpecs
, functionArgTypes, functionResultType, functionArgResultTypes
, functionType
, functionArgNames, functionBody, functionImplementation
, FunctionDefTuple, functionToDef, functionFromDef
, FunctionImpl(..)
, TypeVarName, TypeConsName, Type(..)
, typeBool, typeChar, typeNum, typeString
, typeList, typeFunction
, Env, emptyEnv, makeEnv, extendEnv, envInsertL, envPop
, envIns, envSet, envGet
, envGetFunction, envLookup, envLookupFunction
, envSymbols, envFunctionSymbols, envFunctions
, eval, evalWithLimit, stackSize, apply
, newUndefinedFunction
, ePlus, eTimes, eMinus, eDiv, eMod
, eAdd1, eSub1
, eEq, eNe, eGt, eGe, eLt, eLe
, eZerop, ePositivep, eNegativep
, baseEnv)
where
import Data.Map as Map hiding (filter, foldl, map, null)
import Data.List as List
import Data.Number.Sifflet
import Data.Sifflet.Tree as T
import Text.Sifflet.Pretty
import Text.Sifflet.Repr ()
import Language.Sifflet.Util
eNegate :: Expr -> SuccFail Expr
eNegate expr =
case expr of
ENumber n -> Succ $ ENumber (negate n)
_ -> Fail $ "eNegate: cannot handle" ++ show expr
newtype Symbol = Symbol String
deriving (Eq, Read, Show)
instance Pretty Symbol where
pretty (Symbol s) = s
instance Repr Symbol where repr (Symbol s) = s
type OStr = String
type OBool = Bool
type OChar = Char
data Expr = EUndefined
| ESymbol Symbol
| EBool Bool
| EChar Char
| ENumber Number
| EString String
| EIf Expr Expr Expr
| EList [Expr]
| ELambda Symbol Expr
| EApp Expr Expr
| ECall Symbol [Expr]
| EOp Operator Expr Expr
| EGroup Expr
deriving (Eq, Show)
instance Repr Expr where
repr e =
case e of
EUndefined -> "*undefined*"
ESymbol s -> repr s
EBool b -> repr b
EChar c -> repr c
ENumber n -> repr n
EString s -> show s
EIf t a b -> par "if" (map repr [t, a, b])
EList xs -> if exprIsLiteral e
then reprList "[" ", " "]" xs
else error ("Expr.repr: EList expression is non-literal: "
++ show e)
ELambda x body -> par "lambda" [repr x , "->", repr body]
EApp f arg -> par (repr f) [repr arg]
ECall (Symbol fname) args -> par fname (map repr args)
EOp op left right -> unwords [repr left, opName op, repr right]
EGroup e' -> "(" ++ repr e' ++ ")"
toLambdaExpr :: [String] -> Expr -> SuccFail Expr
toLambdaExpr args body =
case args of
[] -> Fail "toLambdaExpr: no arguments; at least one needed"
a:[] -> Succ $ ELambda (Symbol a) body
a:as -> do
{
expr <- toLambdaExpr as body
; Succ $ ELambda (Symbol a) expr
}
callToApp :: Expr -> Expr
callToApp expr =
case expr of
ECall fsym args -> mapply (ESymbol fsym) args
_ -> error "callToApp: requires ECall expression"
mapply :: Expr -> [Expr] -> Expr
mapply fexpr args =
case args of
[] -> error "mapply: no argument, cannot happen"
arg:[] -> EApp fexpr arg
arg:args' -> mapply (EApp fexpr arg) args'
appToCall :: Expr -> Expr
appToCall expr =
case expr of
EApp f arg -> mcall f [arg]
_ -> error "appToCall: requires an EApp expression"
mcall :: Expr -> [Expr] -> Expr
mcall f args =
case f of
ESymbol fsym -> ECall fsym args
EApp g arg -> mcall g (arg:args)
_ ->
error "mcall: function must be represented as a symbol or an EApp"
exprIsExtended :: Expr -> Bool
exprIsExtended e =
case e of
EOp _ _ _ -> True
EGroup _ -> True
EIf t a b -> exprIsExtended t ||
exprIsExtended a ||
exprIsExtended b
EList xs -> any exprIsExtended xs
ELambda _ body -> exprIsExtended body
ECall (Symbol _) args -> any exprIsExtended args
_ -> False
exprIsLiteral :: Expr -> Bool
exprIsLiteral e =
case e of
EBool _ -> True
EChar _ -> True
ENumber _ -> True
EString _ -> True
EList es -> all exprIsLiteral es
EGroup _e' -> True
_ -> False
exprIsAtomic :: Expr -> Bool
exprIsAtomic e =
case e of
ESymbol _ -> True
EList _ -> True
_ -> exprIsLiteral e
exprIsCompound :: Expr -> Bool
exprIsCompound = not . exprIsAtomic
eSymbol, eSym :: String -> Expr
eSymbol = ESymbol . Symbol
eSym = eSymbol
eInt :: Integer -> Expr
eInt = ENumber . Exact
eString :: OStr -> Expr
eString = EString
eChar :: OChar -> Expr
eChar = EChar
eFloat :: Double -> Expr
eFloat = ENumber . Inexact
eBool :: Bool -> Expr
eBool = EBool
eFalse, eTrue :: Expr
eFalse = eBool False
eTrue = eBool True
eIf :: Expr -> Expr -> Expr -> Expr
eIf = EIf
eList :: [Expr] -> Expr
eList = EList
eCall :: String -> [Expr] -> Expr
eCall = ECall . Symbol
data Operator = Operator {opName :: String
, opPrec :: Precedence
, opAssoc :: Bool
, opGrouping :: OperatorGrouping
}
deriving (Eq, Show)
instance Pretty Operator where
pretty = opName
type Precedence = Int
data OperatorGrouping = GroupLtoR | GroupRtoL | GroupNone
deriving (Eq, Show)
data Value = VBool OBool
| VChar OChar
| VNumber Number
| VString OStr
| VFun Function
| VList [Value]
deriving (Eq, Show)
instance Repr Value where
repr (VBool b) = show b
repr (VChar c) = show c
repr (VNumber n) = show n
repr (VString s) = show s
repr (VFun f) = repr f
repr (VList vs) = reprList "[" ", " "]" vs
valueFunction :: Value -> Function
valueFunction value =
case value of
VFun function -> function
_ -> error "valueFunction: non-function value"
type EvalResult = EvalRes Value
data EvalRes e = EvalOk e | EvalError String | EvalUntried
deriving (Eq, Show)
instance Functor EvalRes where
fmap f (EvalOk v) = EvalOk (f v)
fmap _ (EvalError s) = EvalError s
fmap _ EvalUntried = EvalUntried
instance Applicative EvalRes where
pure = EvalOk
EvalOk f <*> EvalOk v = EvalOk (f v)
EvalOk _ <*> EvalError s = EvalError s
EvalOk _ <*> EvalUntried = EvalUntried
EvalError s <*> _ = EvalError s
EvalUntried <*> _ = EvalUntried
instance Monad EvalRes where
EvalOk value >>= f = f value
EvalError e >>= _f = EvalError e
EvalUntried >>= _f = EvalUntried
return = EvalOk
fail = EvalError
exprToValue :: Expr -> SuccFail Value
exprToValue expr =
case eval expr baseEnv of
EvalOk value -> Succ value
EvalError msg -> Fail msg
EvalUntried -> error "exprToValue: eval resulted in EvalUntried"
valueToLiteral :: Value -> SuccFail Expr
valueToLiteral v =
case v of
VBool b -> Succ $ EBool b
VChar c -> Succ $ EChar c
VNumber n -> Succ $ ENumber n
VString s -> Succ $ EString s
VList vs -> mapM valueToLiteral vs >>= Succ . EList
VFun _f -> Fail "cannot convert function to literal expression"
valueToLiteral' :: Value -> Expr
valueToLiteral' v = case valueToLiteral v of
Fail msg -> error ("valueToLiteral: " ++ msg)
Succ e -> e
literalToValue :: Expr -> Value
literalToValue e =
case e of
EBool b -> VBool b
EChar c -> VChar c
ENumber n -> VNumber n
EString s -> VString s
EList es -> if exprIsLiteral e
then VList (map literalToValue es)
else errcats ["literalToValue: ",
"non-literal list expression: ",
show e]
_ -> errcats ["literalToValue: non-literal or extended expression: " ,
show e]
type TypeVarName = String
type TypeConsName = String
data Type = TypeVar TypeVarName
| TypeCons TypeConsName [Type]
deriving (Eq)
instance Show Type where
show (TypeVar vname) = vname
show (TypeCons ctor ts) =
case ts of
[] -> ctor
(t:ts') ->
case ctor of
"List" -> "[" ++ show t ++ "]"
"Function" -> "(" ++ show t ++ " -> " ++
show (head ts') ++ ")"
_ -> "(" ++ ctor ++ (unwords (map show ts)) ++ ")"
typeToArity :: Type -> Int
typeToArity atype =
case atype of
TypeCons "Function" [_, next] -> 1 + typeToArity next
_ -> 0
primType :: TypeConsName -> Type
primType tname = TypeCons tname []
typeBool, typeChar, typeNum, typeString :: Type
typeBool = primType "Bool"
typeChar = primType "Char"
typeNum = primType "Num"
typeString = primType "String"
typeList :: Type -> Type
typeList t = TypeCons "List" [t]
typeFunction :: [Type] -> Type -> Type
typeFunction atypes rtype =
let func a b = TypeCons "Function" [a, b]
in case atypes of
[] -> error "typeFunction: empty argument type list"
atype:[] -> func atype rtype
atype:atypes' -> func atype (typeFunction atypes' rtype)
newtype Functions = Functions [Function]
deriving (Eq, Show)
data Function = Function (Maybe String)
[Type]
Type
FunctionImpl
deriving (Show)
data ArgSpec = ArgSpec {argName :: String,
argInlets :: Int
}
deriving (Eq, Show)
aspecsLookup :: String -> [ArgSpec] -> Maybe Int
aspecsLookup name specs =
case specs of
[] -> Nothing
s:ss ->
if argName s == name
then Just (argInlets s)
else aspecsLookup name ss
functionArgSpecs :: Function -> [ArgSpec]
functionArgSpecs f@(Function _ argTypes _ _) =
[ArgSpec {argName = n, argInlets = typeToArity t} |
(n, t) <- zip (functionArgNames f) argTypes]
data FunctionImpl = Primitive ([Value] -> EvalResult)
| Compound [String] Expr
instance Show FunctionImpl where
show (Primitive _) = "<primitive function>"
show (Compound args body) =
concat ["Compound function, args = " ++ show args ++
"; body = " ++ show body]
instance Read FunctionImpl where
readsPrec _ _ = error "readsPrec not implemented for FunctionImpl"
instance Repr Function where
repr f =
let name = functionName f
in case functionImplementation f of
Primitive _ -> "<primfunc " ++ name ++ ">"
Compound _args _body -> "<func " ++ name ++ ">"
newUndefinedFunction :: String -> [String] -> Function
newUndefinedFunction name argnames =
let (atypes, rtype) = undefinedTypes argnames
impl = Compound argnames EUndefined
in Function (Just name) atypes rtype impl
undefinedTypes :: [String] -> ([Type], Type)
undefinedTypes argnames =
let atypes = [TypeVar ('_' : name) | name <- argnames]
rtype = TypeVar "_result"
in (atypes, rtype)
functionName :: Function -> String
functionName (Function mname _ _ _) =
case mname of
Just name -> name
Nothing -> "(unnamed)"
functionNArgs :: Function -> Int
functionNArgs = length . functionArgTypes
functionArgTypes :: Function -> [Type]
functionArgTypes (Function _ argtypes _ _) = argtypes
functionResultType :: Function -> Type
functionResultType (Function _ _ rtype _) = rtype
functionArgResultTypes :: Function -> ([Type], Type)
functionArgResultTypes f = (functionArgTypes f, functionResultType f)
functionType :: Function -> Type
functionType (Function _ argTs resultT _) = typeFunction argTs resultT
functionImplementation :: Function -> FunctionImpl
functionImplementation (Function _ _ _ impl) = impl
functionArgNames :: Function -> [String]
functionArgNames f = case functionImplementation f of
Primitive _ ->
["dummy" | _t <- functionArgTypes f]
Compound args _body -> args
type FunctionDefTuple = (String, [String], [Type], Type, Expr)
functionToDef :: Function -> FunctionDefTuple
functionToDef (Function mname argTypes resType impl) =
case impl of
Primitive _ -> error "functionToDef: primitive function"
Compound argNames body ->
case mname of
Nothing -> error "functionToDef: unnamed function"
Just name -> (name, argNames, argTypes, resType, body)
functionFromDef :: FunctionDefTuple -> Function
functionFromDef (name, argNames, argTypes, resType, body) =
Function (Just name) argTypes resType (Compound argNames body)
functionBody :: Function -> Expr
functionBody f = case functionImplementation f of
Primitive _fp ->
errcats ["functionBody:",
"no body available for primitive function"]
Compound _args body -> body
instance Eq Function where
f1 == f2 =
let Function mname1 atypes1 anames1 impl1 = f1
Function mname2 atypes2 anames2 impl2 = f2
in case (impl1, impl2) of
(Primitive _, Primitive _) -> mname1 == mname2
(Compound args1 body1, Compound args2 body2 ) ->
mname1 == mname2 &&
atypes1 == atypes2 &&
anames1 == anames2 &&
args1 == args2 &&
body1 == body2
_ -> False
type EnvFrame = Map String Value
type Env = [EnvFrame]
type Binding = (String, Value)
emptyEnv :: Env
emptyEnv = makeEnv [] []
makeEnv :: [String] -> [Value] -> Env
makeEnv names values = extendEnv names values []
extendEnv :: [String] -> [Value] -> Env -> Env
extendEnv names values env = fromList (zip names values) : env
envInsertL :: Env -> [String] -> [Value] -> Env
envInsertL env names values =
case env of
[] -> error "envInsertL: empty list"
f : fs ->
let ins :: EnvFrame -> Binding -> EnvFrame
ins frame (name, value) = Map.insert name value frame
in foldl ins f (zip names values) : fs
envIns :: Env -> String -> Value -> Env
envIns env name value =
case env of
[] -> error "envIns: empty list"
f : fs -> Map.insert name value f : fs
envSet :: Env -> String -> Value -> Env
envSet env name value =
let loop :: Env -> Maybe Env
loop env1 =
case env1 of
[] -> Nothing
f:fs ->
case Map.lookup name f of
Just _ -> Just (envIns env1 name value)
Nothing ->
do
fs' <- loop fs
return (f:fs')
in case loop env of
Just result -> result
Nothing -> envIns env name value
envGet :: Env -> String -> Value
envGet env name = case envLookup env name of
Just value -> value
Nothing -> errcats ["envGet: unbound variable:", name]
envGetFunction :: Env -> String -> Function
envGetFunction env name = func
where VFun func = envGet env name
envLookup :: Env -> String -> Maybe Value
envLookup env name =
case env of
[] -> Nothing
f:fs ->
case Map.lookup name f of
Just value -> Just value
Nothing -> envLookup fs name
envLookupFunction :: Env -> String -> Maybe Function
envLookupFunction env name =
case envLookup env name of
Nothing -> Nothing
Just value ->
case value of
VFun function -> Just function
_ -> Nothing
envSymbols :: Env -> [String]
envSymbols env =
case env of
[] -> []
f : fs -> keys f ++ envSymbols fs
envFunctionSymbols :: Env -> [String]
envFunctionSymbols env =
let isFunction s = case envGet env s of
VFun _ -> True
_ -> False
in [s | s <- envSymbols env, isFunction s]
envFunctions :: Env -> Functions
envFunctions env =
Functions (map (envGetFunction env)
(envFunctionSymbols env))
envPop :: Env -> Env
envPop env =
case env of
[] -> error "envPop: empty list"
_f:fs -> fs
unbound :: String -> Env -> Bool
unbound name env = envLookup env name == Nothing
stackSize :: Int
stackSize = 1000
eval :: Expr -> Env -> EvalResult
eval expr env = evalWithLimit expr env stackSize
evalWithLimit :: Expr -> Env -> Int -> EvalResult
evalWithLimit expr env stacksize =
if stacksize <= 0
then EvalError "stack overflow"
else
let stacksize' = pred stacksize in
case expr of
EUndefined -> EvalError "undefined"
ESymbol (Symbol name) ->
case envLookup env name of
Nothing -> EvalError $ "unbound variable: " ++ name
Just value -> EvalOk value
EBool b -> EvalOk (VBool b)
EChar c -> EvalOk (VChar c)
ENumber n -> EvalOk (VNumber n)
EString n -> EvalOk (VString n)
EIf t a b ->
case evalWithLimit t env stacksize' of
EvalOk (VBool True) -> evalWithLimit a env stacksize'
EvalOk (VBool False) -> evalWithLimit b env stacksize'
result -> result
ELambda _ _ -> error "evalWithLimit: not implemented for lambda expr"
ECall fsym args ->
case evalWithLimit (ESymbol fsym) env stacksize' of
EvalOk f ->
case mapM (\ a -> evalWithLimit a env stacksize') args of
EvalOk argvalues -> apply f argvalues env stacksize'
EvalError e -> EvalError e
EvalUntried -> EvalUntried
err -> err
EList elist ->
case mapM (\ elt -> evalWithLimit elt env stacksize') elist of
EvalOk values -> EvalOk (VList values)
EvalError e -> EvalError e
EvalUntried -> EvalUntried
_ -> errcats ["evalWithLimit: extended expression not supported",
show expr]
apply :: Value -> [Value] -> Env -> Int -> EvalResult
apply fvalue args env stacksize =
case fvalue of
VFun f ->
case functionImplementation f of
Primitive pf -> pf args
Compound formalArgs body ->
evalWithLimit body (extendEnv formalArgs args env) stacksize
not_a_function ->
EvalError ("apply: first arg is not a function: " ++
show not_a_function)
ePlus :: Expr -> Expr -> Expr
ePlus e1 e2 = eCall "+" [e1, e2]
eTimes :: Expr -> Expr -> Expr
eTimes e1 e2 = eCall "*" [e1, e2]
eMinus, eDiv, eMod :: Expr -> Expr -> Expr
eMinus e1 e2 = eCall "-" [e1, e2]
eDiv e1 e2 = eCall "div" [e1, e2]
eMod e1 e2 = eCall "mod" [e1, e2]
eAdd1, eSub1 :: Expr -> Expr
eAdd1 e1 = eCall "add1" [e1]
eSub1 e1 = eCall "sub1" [e1]
eEq, eNe, eGt, eGe, eLt, eLe :: Expr -> Expr -> Expr
eEq e1 e2 = eCall "==" [e1, e2]
eNe e1 e2 = eCall "/=" [e1, e2]
eGt e1 e2 = eCall ">" [e1, e2]
eGe e1 e2 = eCall ">=" [e1, e2]
eLt e1 e2 = eCall "<" [e1, e2]
eLe e1 e2 = eCall "<=" [e1, e2]
eZerop, ePositivep, eNegativep :: Expr -> Expr
eZerop e1 = eCall "zero?" [e1]
ePositivep e1 = eCall "positive?" [e1]
eNegativep e1 = eCall "negative?" [e1]
primitiveFunctions :: [Function]
primitiveFunctions = [
primN2N "+" (+),
primN2N "-" (),
primN2N "*" (*),
primIntDiv,
primIntMod,
primFloatDiv,
primN1N "add1" succ,
primN1N "sub1" pred,
primN2B "==" (==),
primN2B "/=" (/=),
primN2B ">" (>),
primN2B ">=" (>=),
primN2B "<" (<),
primN2B "<=" (<=),
primN1B "zero?" eqZero,
primN1B "positive?" gtZero,
primN1B "negative?" ltZero,
prim "null" [typeList (TypeVar "a")]
typeBool primNull,
prim "head" [typeList (TypeVar "b")]
(TypeVar "b")
primHead,
prim "tail" [typeList (TypeVar "c")]
(typeList (TypeVar "c"))
primTail,
prim ":" [TypeVar "d", typeList (TypeVar "d")]
(typeList (TypeVar "d"))
primCons
]
type PFun = [Value] -> EvalResult
prim :: String -> [Type] -> Type -> PFun -> Function
prim name atypes rtype = Function (Just name) atypes rtype . Primitive
primIntDivMod :: String -> (Number -> Number -> Number) -> Function
primIntDivMod name oper =
let func args =
let err msg = EvalError $ concat [name, ": ", msg,
" (", show args, ")"]
in case args of
[VNumber a, VNumber b] ->
if b == 0
then err "zero divisor"
else if isExact a && isExact b
then EvalOk $ VNumber (oper a b)
else err "arguments must be exact numbers"
_ -> err "wrong type or number of arguments"
in prim name [typeNum, typeNum] typeNum func
primIntDiv, primIntMod :: Function
primIntDiv = primIntDivMod "div" div
primIntMod = primIntDivMod "mod" mod
primFloatDiv :: Function
primFloatDiv =
let divide args =
case args of
[VNumber x, VNumber y] -> EvalOk $ VNumber (x / y)
_ -> EvalError $ "/: invalid args: " ++ show args
in prim "/" [typeNum, typeNum] typeNum divide
primArgCountError :: String -> EvalResult
primArgCountError name =
errcat [name, ": wrong number of arguments in primitive function"]
primNull :: PFun
primNull args =
case args of
[VList list] -> EvalOk $ VBool (List.null list)
[_] -> EvalError "null: not a list"
_ -> primArgCountError "primNull"
primHead :: PFun
primHead args =
case args of
[VList (x : _xs)] -> EvalOk x
[VList []] -> EvalError "head: empty list"
[_] -> EvalError "head: not a list"
_ -> primArgCountError "primHead"
primTail :: PFun
primTail args =
case args of
[VList (_x : xs)] -> EvalOk $ VList xs
[VList []] -> EvalError "tail: empty list"
[_] -> EvalError "tail: not a list"
_ -> primArgCountError "primTail"
primCons :: PFun
primCons args =
case args of
[x, VList xs] -> EvalOk $ VList (x:xs)
[_, _] -> EvalError "cons: second argument not a list"
_ -> primArgCountError "primCons"
primN2N :: String -> (Number -> Number -> Number) -> Function
primN2N name fn =
let impl args =
case args of
[VNumber x, VNumber y] -> EvalOk $ VNumber (fn x y)
_ -> EvalError $ name ++ ": invalid args: " ++ show args
in prim name [typeNum, typeNum] typeNum impl
primN1N :: String -> (Number -> Number) -> Function
primN1N name fn =
let impl args =
case args of
[VNumber x] -> EvalOk $ VNumber (fn x)
_ -> EvalError $ name ++ ": invalid args: " ++ show args
in prim name [typeNum] typeNum impl
primN2B :: String -> (Number -> Number -> OBool) -> Function
primN2B name fn =
let impl args =
case args of
[VNumber x, VNumber y] -> EvalOk $ VBool (fn x y)
_ -> EvalError $ name ++ ": invalid args: " ++ show args
in prim name [typeNum, typeNum] typeBool impl
primN1B :: String -> (Number -> Bool) -> Function
primN1B name fn =
let impl args =
case args of
[VNumber x] -> EvalOk $ VBool (fn x)
_ -> EvalError $ name ++ ": invalid args: " ++ show args
in prim name [typeNum] typeBool impl
baseEnv :: Env
baseEnv =
makeEnv (map functionName primitiveFunctions)
(map VFun primitiveFunctions)
exprSymbols :: Expr -> [Symbol]
exprSymbols expr =
nub $ case expr of
EUndefined -> []
ESymbol s -> [s]
EIf t a b -> nub $ concat [exprSymbols t,
exprSymbols a,
exprSymbols b]
ELambda x body -> nub (x : exprSymbols body)
ECall f args ->
case args of
[] -> [f]
a:as -> nub $ concat [exprSymbols a,
exprSymbols (ECall f as)]
EList items -> nub $ concatMap exprSymbols items
_ -> if exprIsExtended expr
then errcats ["exprSymbols: extended expr not supported:",
show expr]
else []
exprVarNames :: Expr -> [String]
exprVarNames expr = [name | (Symbol name) <- exprSymbols expr,
unbound name baseEnv]