Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

mustSatisfyAnyOf fails the expected logic #101

Closed
blamario opened this issue Nov 10, 2021 · 0 comments · Fixed by #166
Closed

mustSatisfyAnyOf fails the expected logic #101

blamario opened this issue Nov 10, 2021 · 0 comments · Fixed by #166
Labels
bug Something isn't working

Comments

@blamario
Copy link

blamario commented Nov 10, 2021

Summary

The function is admittedly completely undocumented, but from its type signature

mustSatisfyAnyOf :: forall i o. [TxConstraints i o] -> TxConstraints i o

and the name, I would expect that it's meant to be equivalent to any, meaning if any of the items in the argument list is satisfied, the result will be satisfied as well. In a bit of pseudo-notation,

satisfied (mustSatisfyAnyOf xs) == any satisfied xs

As a reminder, the TxConstraints type is basically a conjunction of a list of TxConstraint, so it acts as an all; its mempty implementation is an empty list and is always trivially satisfied. So we can expand this to

satisfied (mustSatisfyAnyOf xs) == any satisfied xs == any (all satisfied) xs

That's not what happens. The actual function implementation is

mustSatisfyAnyOf = singleton . MustSatisfyAnyOf . concatMap txConstraints

The first thing the function does is to take a list of the conjunction lists flatten the list of [[TxConstraint]], so we end up with

satisfied (mustSatisfyAnyOf xs) == any (any satisfied) xs

Steps to reproduce

mustSatisfyAnyOf [mempty]

always fails.

Expected behavior

mustSatisfyAnyOf [mempty]

should be equal to mempty, i.e. it should be trivial to satisfy.

System info (please complete the following information):

@blamario blamario added the bug Something isn't working label Nov 10, 2021
ghost pushed a commit that referenced this issue Dec 3, 2021
@ghost ghost mentioned this issue Dec 3, 2021
8 tasks
ghost pushed a commit that referenced this issue Dec 6, 2021
add contract test

Use any instead of or and map
ghost pushed a commit that referenced this issue Dec 8, 2021
add contract test

Use any instead of or and map
@ghost ghost closed this as completed in #166 Dec 8, 2021
ghost pushed a commit that referenced this issue Dec 8, 2021
add contract test

Use any instead of or and map
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant