Skip to content

Instantly share code, notes, and snippets.

@jfdm
Created November 12, 2018 13:21
Show Gist options
  • Save jfdm/b6b0f7276fd9433293b2728673059753 to your computer and use it in GitHub Desktop.
Save jfdm/b6b0f7276fd9433293b2728673059753 to your computer and use it in GitHub Desktop.
module Sorted
data LessThanOrEq : (x,y : type)
-> Type
where
IsLessThan : Ord type => {x,y : type} -> (prf : compare x y = LT) -> LessThanOrEq x y
IsEqual : Ord type => {x,y : type} -> (prf : compare x y = EQ) -> LessThanOrEq x y
data IsSorted : (list : List type)
-> Type
where
Empty : IsSorted Nil
Single : IsSorted [x]
Pair : (prf : LessThanOrEq x y)
-> IsSorted (y::rest)
-> IsSorted (x::y::rest)
prf : Ord a => (xs : List a) -> {auto prf : IsSorted xs} -> IsSorted xs
prf xs {prf} = prf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment