Skip to content

Commit

Permalink
Merge pull request #4785 from buzden/absurd-for-so
Browse files Browse the repository at this point in the history
Couple of convenience absurd-related functions were added to `Data.So`
  • Loading branch information
melted authored Nov 25, 2019
2 parents b0a55aa + 8cf5fc6 commit 21434e0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion libs/base/Data/So.idr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Data.So
||| If you find yourself using `So` for something other than primitive types,
||| it may be appropriate to define a type of evidence for the property that you
||| care about instead.
data So : Bool -> Type where
data So : Bool -> Type where
Oh : So True

implementation Uninhabited (So False) where
Expand All @@ -23,4 +23,14 @@ choose : (b : Bool) -> Either (So b) (So (not b))
choose True = Left Oh
choose False = Right Oh

||| Absurd when you have proof that both `b` and `not b` is true.
export
soAbsurd : So b -> So (not b) -> Void
soAbsurd sb snb with (sb)
| Oh = uninhabited snb

||| Transmission between usage of value-level `not` and type-level `Not`.
export
soNotToNotSo : So (not b) -> Not (So b)
soNotToNotSo = flip soAbsurd

0 comments on commit 21434e0

Please sign in to comment.