Open ngeiswei opened 9 months ago
I tried the following
(: or (-> Bool Atom Bool))
(= (or False $x) $x)
(= (or True $x) True)
(: and (-> Bool Atom Bool))
(= (and False $x) False)
(= (and True $x) $x)
but it's not any faster.
It's not lazier either, indeed the following
!(and False (trace! "and: not lazy" True))
!(or True (trace! "or: not lazy" False))
outputs
"and: not lazy"
"or: not lazy"
[False]
[True]
It looks like the reason my suggestion above does not work is because or
and and
in stdlib.metta
does not seem to be used by minimal MeTTa. If I introduce lazy-or
and lazy-and
instead as follows:
(: lazy-or (-> Bool Atom Bool))
(= (lazy-or False $x) $x)
(= (lazy-or True $x) True)
(: lazy-and (-> Bool Atom Bool))
(= (lazy-and False $x) False)
(= (lazy-and True $x) $x)
then it works.
Which brings another issue, how to simultaneously type annotate metatypes and regular types? For instance, how to express that an argument should be left unchanged (via the Atom
metatype) but should be of a certain regular type, like Bool
?
This issue is a duplicate of https://github.com/trueagi-io/hyperon-experimental/issues/514
In minimal MeTTa,
or
andand
are implemented as followsAt first sight it looks like an eager implementation. It is possible to replace it by a lazy implementation?