clash-lib-1.8.4: Clash: a functional hardware description language - As a library

Copyright | (C) 2018 QBayLogic
License | BSD2 (see the file LICENSE)
Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com>
Safe Haskell | None
Language | Haskell2010

Clash.Util.Graph

Description

Collection of utilities

Synopsis

- topSort :: [(Unique, a)] -> [(Unique, Unique)] -> Either String [a]
- reverseTopSort :: [(Unique, a)] -> [(Unique, Unique)] -> Either String [a]
- callGraphBindings :: BindingMap -> Id -> [Term]

# Documentation

topSort Source #

Arguments

:: [(Unique, a)] | Nodes
-> [(Unique, Unique)] | Edges
-> Either String [a] | Error message or topologically sorted nodes

See: https://en.wikipedia.org/wiki/Topological_sorting. This function errors if edges mention nodes not mentioned in the node list or if the given graph contains cycles.

reverseTopSort Source #

Arguments

:: [(Unique, a)] | Nodes
-> [(Unique, Unique)] | Edges
-> Either String [a] | Reversely, topologically sorted nodes

Same as `reverse (topSort nodes edges)` if alternative representations are considered the same. That is, topSort might produce multiple answers and still deliver on its promise of yielding a topologically sorted node list. Likewise, this function promises one of those lists in reverse, but not necessarily the reverse of topSort itself.

callGraphBindings Source #

Arguments

:: BindingMap | All bindings
-> Id | Root of the call graph
-> [Term] |

Get all the terms corresponding to a call graph