{"id":16661698,"url":"https://github.com/ennocramer/monad-dijkstra","last_synced_at":"2025-10-30T08:58:44.332Z","repository":{"id":50319802,"uuid":"53955748","full_name":"ennocramer/monad-dijkstra","owner":"ennocramer","description":"Haskell monad transformer for weighted, non-deterministic computation","archived":false,"fork":false,"pushed_at":"2025-01-26T14:47:08.000Z","size":38,"stargazers_count":30,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T20:11:21.211Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ennocramer.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-15T15:24:13.000Z","updated_at":"2025-01-26T14:47:12.000Z","dependencies_parsed_at":"2024-10-27T11:47:51.908Z","dependency_job_id":"a62b6d09-91b9-41b4-866c-ccaca94bd01d","html_url":"https://github.com/ennocramer/monad-dijkstra","commit_stats":{"total_commits":42,"total_committers":4,"mean_commits":10.5,"dds":0.09523809523809523,"last_synced_commit":"4e53f92a72be996dcdf4c646ad540de45cc3f3c8"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ennocramer%2Fmonad-dijkstra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ennocramer%2Fmonad-dijkstra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ennocramer%2Fmonad-dijkstra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ennocramer%2Fmonad-dijkstra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ennocramer","download_url":"https://codeload.github.com/ennocramer/monad-dijkstra/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557767,"owners_count":20958047,"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":[],"created_at":"2024-10-12T10:35:52.886Z","updated_at":"2025-10-30T08:58:39.280Z","avatar_url":"https://github.com/ennocramer.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# monad-dijkstra\n\n[![Hackage][hackage-image]][hackage-url]\n[![Build Status][ci-image]][ci-url]\n[![License][license-image]][license-url]\n\nA monad transformer for weighted graph searches using Dijkstra's or A*\nalgorithm.\n\n## The SearchT Monad Transformer\n\nThis library implements the `SearchT` monad transformer, in which\nmonadic computations can be associated with costs and alternative\ncomputational paths can be explored concurrently.  The API is built in\nterms of the `Alternative` and `MonadPlus` type classes and a `cost`\nfunction.\n\nThe `runSearch` function lazily evaluates all alternative\ncomputations, returning non-empty solutions in order of increasing\ncost.  When forcing only the head of the result list, the function\nperforms the minimal amount of work necessary to guarantee the optimal\nsolution, i.e. with the least cost, is returned first.\n\nThe `runSearchT` function will also evaluate all alternatice\ncomputations in order of increasing cost, but the resulting list will\nlikely not be lazy, depending bind operation of the underlying monad.\nThe `collapse` function can be used to terminate the search when all\ninteresting solutions have been found.\n\n## Computational Cost\n\nThe cost of a computation is set using the `cost` function. Repeated\ncalls within a branch of computation will accumulate the cost using\n`mappend` from the type's `Monoid` instance. In addition to the\ncomputational cost expended, the `cost` function also accepts a cost\nestimate for the rest of computation. Subsequent calls to `cost` will\nreset this estimate.\n\n## Limitations\n\nAny type that satisfies the `Monoid` and `Ord` type classes may be\nused as a cost values.  However, the internal evaluation algorithm\nrequires that costs not be negative. That is, for any costs `a` and\n`b`, `a \u003c\u003e b \u003e= a \u0026\u0026 a \u003c\u003e b \u003e= b`.\n\nFor the `runSearchT` function to generate solutions in the correct\norder, estimates must never overestimate the cost of a computation. If\nthe cost of a branch is over-estimated or a negative cost is applied,\n`runSearchT` may return results in the wrong order.\n\n## Usage Example\n\n```haskell\ntype Location = ...\ntype Distance = ...\n\ndistance :: Location -\u003e Location -\u003e Distance\ndistance = ...\n\nneighbors :: Location -\u003e [(Location, Distance)]\nneighbors = ...\n\nshortedtRoute :: Location -\u003e Location -\u003e Maybe (Distance, [Location])\nshortestRoute from to = listToMaybe $ runSearch $ go [from]\n  where\n    go ls = if head ls == to\n               then return ls\n               else msum $ flip map (neighbors (head ls)) $\n                   \\(l, d) -\u003e cost d (distance l to) $ go (l : ls)\n```\n\u003c!-- Markdown link \u0026 img dfn's --\u003e\n[hackage-image]: https://img.shields.io/hackage/v/monad-dijkstra.svg?style=flat\n[hackage-url]: https://hackage.haskell.org/package/monad-dijkstra\n[ci-image]: https://github.com/ennocramer/monad-dijkstra/workflows/CI%20Pipeline/badge.svg\n[ci-url]: https://github.com/ennocramer/monad-dijkstra/actions?query=workflow%3A%22CI+Pipeline%22\n[license-image]: https://img.shields.io/badge/license-BSD--3--Clause-blue?style=flat-square\n[license-url]: https://github.com/ennocramer/monad-dijkstra/blob/master/LICENSE.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fennocramer%2Fmonad-dijkstra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fennocramer%2Fmonad-dijkstra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fennocramer%2Fmonad-dijkstra/lists"}