{"id":18695070,"url":"https://github.com/rybla/liquid-monadic-selectionsort","last_synced_at":"2025-11-08T13:30:32.094Z","repository":{"id":46027855,"uuid":"421664290","full_name":"rybla/liquid-monadic-selectionsort","owner":"rybla","description":null,"archived":false,"fork":false,"pushed_at":"2022-02-08T18:41:40.000Z","size":135,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-28T03:20:41.052Z","etag":null,"topics":["liquid-haskell"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rybla.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-27T03:29:58.000Z","updated_at":"2022-01-08T20:59:22.000Z","dependencies_parsed_at":"2022-08-26T03:11:55.335Z","dependency_job_id":null,"html_url":"https://github.com/rybla/liquid-monadic-selectionsort","commit_stats":null,"previous_names":["rybla/liquid-monadic-selectionsort"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rybla%2Fliquid-monadic-selectionsort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rybla%2Fliquid-monadic-selectionsort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rybla%2Fliquid-monadic-selectionsort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rybla%2Fliquid-monadic-selectionsort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rybla","download_url":"https://codeload.github.com/rybla/liquid-monadic-selectionsort/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239558907,"owners_count":19658927,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["liquid-haskell"],"created_at":"2024-11-07T11:13:50.007Z","updated_at":"2025-11-08T13:30:32.038Z","avatar_url":"https://github.com/rybla.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# liquid-monadic-selectionsort\n\n## Pure Selection Sort\n\n### Sorting\n\n```haskell\n{-@\nsort :: List -\u003e List\n@-}\nsort :: List -\u003e List\nsort Nil = Nil\nsort (Cons x Nil) = Cons x Nil\nsort (Cons x xs) =\n  let Cons x' xs' = select (Cons x xs)\n   in Cons x' (sort xs')\n\n{-@\nselect :: {xs:List | 0 \u003c lng xs} -\u003e {xs':List | lng xs == lng xs'}\n@-}\nselect :: List -\u003e List\nselect (Cons x Nil) = Cons x Nil\nselect (Cons x1 (Cons x2 xs)) =\n  if x1 \u003c= x2\n    then\n      let (Cons x' xs') = select (Cons x1 xs)\n       in Cons x' (Cons x2 xs')\n    else\n      let (Cons x' xs') = select (Cons x2 xs)\n       in Cons x' (Cons x1 xs')\n```\n\n### Correctness Specifications\n\n```haskell\n{-@\nsorted_sort :: xs:List -\u003e Sorted {sort xs}\n@-}\nsorted_sort :: List -\u003e Sorted\n\n{-@\npermuted_sort :: xs:List -\u003e Permuted {xs} {sort xs}\n@-}\npermuted_sort :: List -\u003e Permuted\n```\n\n### Proofs of Correctness\n\nSee module `SelectionSort/Pure.hs`.\n\n### Predicates\n\n```haskell\n-- the list XS is sorted\n{-@\ntype Sorted XS = {i:Int | inBounds xs i} -\u003e {j:Int | inBounds xs j \u0026\u0026 i \u003c= j} -\u003e {index XS i \u003c= index XS j}\n@-}\ntype Sorted = Int -\u003e Int -\u003e Proof\n\n-- the list XS is a permutation of the list YS\n{-@\ntype Permuted XS YS = z:Int -\u003e {permutedAt XS YS z}\n@-}\ntype Permuted = Int -\u003e Proof\n\npermutedAt :: List -\u003e List -\u003e Int -\u003e Bool\npermutedAt xs ys z = count xs z == count ys z\n\n-- the int X is less than or equal to each element of XS\n{-@\ntype LeAll X XS = y:Int -\u003e {contains XS y =\u003e X \u003c= y}\n@-}\ntype LeAll = Int -\u003e Proof\n```\n\n### Performance\n\n```\nstack build  69.37s user 8.18s system 93% cpu 1:22.88 total\n```\n\n## Stateful Selection Sort\n\nTODO\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frybla%2Fliquid-monadic-selectionsort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frybla%2Fliquid-monadic-selectionsort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frybla%2Fliquid-monadic-selectionsort/lists"}