diff --git a/src/Quox/Error.idr b/src/Quox/Error.idr index a78cabb..bbe8b0f 100644 --- a/src/Quox/Error.idr +++ b/src/Quox/Error.idr @@ -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