Data.Type.Dec

dec-0.0.6: Decidable propositions.

Safe Haskell | Safe
Language | Haskell2010

Data.Type.Dec

Contents

- Types
- Neg combinators
- Dec combinators
- Boring

Synopsis

- type Neg a = a -> Void
- data Dec a
  - = Yes a
  - | No (Neg a)
- class Decidable a where
  - decide :: Dec a
- toNegNeg :: a -> Neg (Neg a)
- tripleNeg :: Neg (Neg (Neg a)) -> Neg a
- contradict :: (a -> Neg b) -> b -> Neg a
- contraposition :: (a -> b) -> Neg b -> Neg a
- decNeg :: Dec a -> Dec (Neg a)
- decShow :: Show a => Dec a -> String
- decToMaybe :: Dec a -> Maybe a
- decToBool :: Dec a -> Bool
- boringYes :: Boring a => Dec a
- absurdNo :: Absurd a => Dec a

# Types

type Neg a = a -> Void #

Intuitionistic negation.

data Dec a #

Decidable (nullary) relations.

Constructors

Yes a |
No (Neg a) |

#### Instances

Instances details

Decidable a => Boring (Dec a) # | This relies on the fact that `a` is proposition in h-Prop sense. Since: 0.0.5
Instance details Defined in Data.Type.Dec Methods boring :: Dec a #
Eq a => Eq (Dec a) # |
Instance details Defined in Data.Type.Dec Methods (==) :: Dec a -> Dec a -> Bool # (/=) :: Dec a -> Dec a -> Bool #
Ord a => Ord (Dec a) # | `decToBool` respects this ordering. Note: yet if you have `p :: a` and `p :: `Neg` a`, something is wrong.
Instance details Defined in Data.Type.Dec Methods compare :: Dec a -> Dec a -> Ordering # (<) :: Dec a -> Dec a -> Bool # (<=) :: Dec a -> Dec a -> Bool # (>) :: Dec a -> Dec a -> Bool # (>=) :: Dec a -> Dec a -> Bool # max :: Dec a -> Dec a -> Dec a # min :: Dec a -> Dec a -> Dec a #

class Decidable a where #

Class of decidable types.

## Law

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

Note: We'd want to have decidable equality `:~:` here too, but that seems to be a deep dive into singletons.

Methods

decide :: Dec a #

#### Instances

Instances details

Decidable Void # | `Void` is falsehood. Since: 0.0.5
Instance details Defined in Data.Type.Dec Methods decide :: Dec Void #
Decidable () # | `()` is truth. Since: 0.0.5
Instance details Defined in Data.Type.Dec Methods decide :: Dec () #
(Decidable a, Decidable b) => Decidable (a, b) # | Products of decidable propositions are decidable Since: 0.0.5
Instance details Defined in Data.Type.Dec Methods decide :: Dec (a, b) #

# Neg combinators

toNegNeg :: a -> Neg (Neg a) #

We can negate anything twice.

Double-negation elimination is inverse of `toNegNeg` and generally impossible.

tripleNeg :: Neg (Neg (Neg a)) -> Neg a #

Triple negation can be reduced to a single one.

contradict :: (a -> Neg b) -> b -> Neg a #

Weak contradiction.

contraposition :: (a -> b) -> Neg b -> Neg a #

A variant of contraposition.

# Dec combinators

decNeg :: Dec a -> Dec (Neg a) #

Flip `Dec` branches.

decShow :: Show a => Dec a -> String #

Show `Dec`.

    >>> decShow $ Yes ()
    "Yes ()"

    >>> decShow $ No id
    "No <toVoid>"

decToMaybe :: Dec a -> Maybe a #

Convert ``Dec` a` to ``Maybe` a`, forgetting the `No` evidence.

decToBool :: Dec a -> Bool #

Convert `Dec` to `Bool`, forgetting the evidence.

# Boring

``Dec` a` can be `Boring` in two ways: When `a` is `Boring` or `Absurd`.

boringYes :: Boring a => Dec a #

`Yes`, it's `boring`.

Since: 0.0.5

absurdNo :: Absurd a => Dec a #

`No`, it's `absurd`.

Since: 0.0.5