Skip to content

Support Duck-typing in filter predicate #608

Open
@Acaccia

Description

The interpreter allows this kind of expression:

(define-private (foo (a (response int bool))) (and (is-ok a) (< (unwrap-panic a) 100)))
(define-private (bar (a (response int uint))) (and (is-ok a) (> (unwrap-panic a) 42))) 

(filter bar (filter foo (list (ok 1) (ok 50))))

Here we filter two times on a list which is inferred to have the type (list 2 (response int NoType)).
However, in the interpreter, the type of the list is inferred after the first call to filter to (list 2 (response int bool)), so the second call to filter fails as it expects another type for the list element.

We need to find a way to support this.

UPDATE: "The Workaround" also has a fix for fold, so it might need the same kind of adaptation for it too.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions