From b1b0beb8a47fa992674a276884de6c6c08df3013 Mon Sep 17 00:00:00 2001 From: logicmoo Date: Sun, 5 Jan 2025 20:54:49 -0800 Subject: [PATCH] Add new type query functions in stdlib_mettalog.metta - Defined `get-vtype`, `get-dtype`, `get-ftype`, and `get-types`. - Updated `get-type` and `get-type-space` for DynSpace contexts. - Improved type annotations for compatibility with evaluation logic. --- prolog/metta_lang/stdlib_mettalog.metta | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/prolog/metta_lang/stdlib_mettalog.metta b/prolog/metta_lang/stdlib_mettalog.metta index a00396269..ed8cd7ca2 100644 --- a/prolog/metta_lang/stdlib_mettalog.metta +++ b/prolog/metta_lang/stdlib_mettalog.metta @@ -81,9 +81,19 @@ (: switch (-> %Undefined% Expression Atom)) (: unify (-> Atom Atom Atom Atom %Undefined%)) -(: get-type (-> Atom Type)) ; get all type declarations for Atom -(: get-type0 (-> Atom Atom)) ; get-type now returns multiple return values.. this act like the old one that reutrns a sngle value + + +(: get-vtype (-> Atom Atom)) ; returns only the first type of a symbol +(: get-vtype (-> Atom hyperon::space::DynSpace Atom)) ; returns only the first type of a symbol + +(: get-types (-> Atom Atom)) ; returns only the first type of a symbol +(: get-types (-> Atom hyperon::space::DynSpace Atom)) ; returns only the first type of a symbol + +(: get-dtype (-> Atom Atom)) ; returns only the data value types of a symbol +(: get-dtype (-> Atom hyperon::space::DynSpace Atom)) ; returns only the data value types of a symbol + (: get-ftype (-> Atom Atom)) ; returns only the function types of a symbol +(: get-ftype (-> Atom hyperon::space::DynSpace Atom)) ; returns only the function types of a symbol (: pragma! (-> Atom Atom (->))) ;(: = (-> Atom Atom %Undefined%)) @@ -1601,7 +1611,7 @@ For example: (@param "Atom to get type for"))) (@return "Type notation or %Undefined% if there is no type for input Atom")) (: get-type (-> Atom Atom)) -(: get-type (-> Atom Atom Atom)) +(: get-type (-> Atom hyperon::space::DynSpace Atom)) (iz get-type-space MeTTa) (@doc get-type-space @@ -1611,7 +1621,7 @@ For example: (@param "Atom to get type for"))) (@return "Type notation or %Undefined% if there is no type for input Atom in provided atomspace")) (iz get-type-space MeTTa) -(: get-type-space (-> Atom Atom Atom)) +(: get-type-space (-> hyperon::space::DynSpace Atom Atom)) (= (get-type-space $space $atom) (get-type $atom $space))