Skip to content

Commit

Permalink
Add new type query functions in stdlib_mettalog.metta
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
TeamSPoon committed Jan 6, 2025
1 parent 687ca1f commit b1b0beb
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions prolog/metta_lang/stdlib_mettalog.metta
Original file line number Diff line number Diff line change
Expand Up @@ -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%))
Expand Down Expand Up @@ -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
Expand All @@ -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))

Expand Down

0 comments on commit b1b0beb

Please sign in to comment.