use stdlib Elem and add note why not also stdlib OpenUnion
This commit is contained in:
parent
2b1a043280
commit
65e45dcc79
1 changed files with 4 additions and 14 deletions
|
@ -1,5 +1,7 @@
|
|||
module Quox.Error
|
||||
|
||||
import Data.List.Elem
|
||||
|
||||
import Control.Monad.Identity
|
||||
import Control.Monad.Trans
|
||||
import Control.Monad.Reader
|
||||
|
@ -10,20 +12,6 @@ import Control.Monad.RWS
|
|||
%default total
|
||||
|
||||
|
||||
||| a proof that an element is in a list. unlike the standard library one, this
|
||||
||| is represented as a single number at runtime.
|
||||
public export
|
||||
data Elem : a -> List a -> Type where
|
||||
Here : x `Elem` (x :: xs)
|
||||
There : x `Elem` xs -> x `Elem` (y :: xs)
|
||||
%builtin Natural Elem
|
||||
|
||||
export
|
||||
Uninhabited (x `Elem` []) where
|
||||
uninhabited Here impossible
|
||||
uninhabited (There _) impossible
|
||||
|
||||
|
||||
||| a representation of a list's length. this is used in the `Ord` instance to
|
||||
||| transform the `Ord` constraints into `Eq`s
|
||||
public export
|
||||
|
@ -40,6 +28,8 @@ record OneOf types where
|
|||
constructor One
|
||||
elem : type `Elem` types
|
||||
1 value : type
|
||||
-- this is basically the same as Data.OpenUnion, but using Elem instead of
|
||||
-- AtIndex is much easier for some stuff here e.g. `get`
|
||||
|
||||
export
|
||||
Uninhabited (OneOf []) where uninhabited x = uninhabited x.elem
|
||||
|
|
Loading…
Reference in a new issue