validate_atom

Function validate_atom 

Source
pub fn validate_atom(space: &DynSpace, atom: &Atom) -> bool
Expand description

Returns true if atom is typed correctly. For example it can be used to check if function arguments have correct types.

ยงExamples

use hyperon_atom::expr;
use hyperon::metta::runner::*;
use hyperon::metta::text::SExprParser;
use hyperon::metta::types::validate_atom;

let metta = Metta::new(None);
metta.run(SExprParser::new("(: foo (-> A B)) (: a A) (: b B)")).unwrap();

let space = metta.space();
assert!(validate_atom(&space, &expr!("foo" "a")));
assert!(!validate_atom(&space, &expr!("foo" "b")));