Skip to content
base
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

Lisp style alists for idris2

λΠ> Data.AList.remove "yo" $ Data.AList.replace "hi" "there" $ addIfUnique "hello" "dude" $ addIfUnique "yo" "man" $ addIfUnique "hi" "fren" Data.AList.empty
MkDPair [("hello", "dude"), ("hi", "there")] Refl

The proof that these lists carry is:

keyInList : Eq a => a -> List (Pair a b) -> Bool
keyInList k [] = False
keyInList k ((k1, v1) :: others) =
  if k == k1 then
    True
  else
    keyInList k others

allKeysUniqueInList : Eq a => List (Pair a b) -> Bool
allKeysUniqueInList [] = True
allKeysUniqueInList ((k, v) :: others) =
  let
    headIsUnique = not (keyInList k others)
    tailsAreUnique = allKeysUniqueInList others
  in
  tailsAreUnique && headIsUnique

I'm hoping both the library itself and the ratty beginner code might be of benefit to others as I feel like I've reached an intermediate stage in my ability to provide data with proofs.

About

Lisp style alists that carry proofs that all elements are unique

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages