Last active
September 13, 2016 20:27
-
-
Save jfdm/23f9e731ddc473861ab6cbfe268e2ea9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Data.List.Constraints | |
import Data.Vect | |
data NotElem : a -> List a -> Type where | |
NotHere : NotElem x [] | |
NotThere : Eq ty => {x,y : ty} -> {auto prf : x /= y = True} -> NotElem x xs -> NotElem x (y::xs) | |
data AllDiff : List a -> Type where | |
EmptyCase : AllDiff Nil | |
OneCase : AllDiff [x] | |
ManyCase : NotElem x xs -> AllDiff xs -> AllDiff (x::xs) | |
data UniqueList : (a : Type) -> List a -> Type where | |
Nil : UniqueList ty Nil | |
(::) : (x : ty) | |
-> (xs : UniqueList ty xs') | |
-> {auto prf : NotElem x xs'} | |
-> {auto prf : AllDiff (x::xs')} | |
-> UniqueList ty (x::xs') | |
UniqueList' : Type -> Type | |
UniqueList' ty = Subset (List ty) (\xs => AllDiff xs) | |
fromList : Eq a | |
=> (xs : List a) | |
-> {auto prf : AllDiff xs} | |
-> UniqueList' a | |
fromList xs {prf} = Element xs prf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment