Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Decidable instances for ->, Neg and Either #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

olafklinke
Copy link

add instances
Decidable a => Decidable (Neg a)
(Decidable a, Decidable b) => Decidable (a -> b)
(Decidable a, Decidable b) => Decidable (Either a b)

add instances
`Decidable a => Decidable (Neg a)`
`(Decidable a, Decidable b) => Decidable (a -> b)`
`(Decidable a, Decidable b) => Decidable (Either a b)`
src/Data/Type/Dec.hs Outdated Show resolved Hide resolved
(Yes _, Yes b) -> Yes (const b)

-- | Disjunctions are decidable
instance forall a b. (Decidable a, Decidable b) => Decidable (Either a b) where
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not lawful instance as it prefers Left over right.

a should be a Proposition, i.e. the Yes answers should be unique.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is actually meant by the 'Yes' answers should be unique? Can you give an example how this breaks? (I don't know the use-case of this library so I can't think of why this instance is bad.) Preferring left over right corresponds to short-circuiting which is generally a welcome property in logic, no?

Decidability for `Neg a` is subsumed by decidability of implication. Avoid overlapping instances.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants