HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

  • Packagefgl-5.8.2.0
  • Exports34
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceMonad.hs

Additional Graph Utilities

4 declarations
valuemapFst :: (a -> b) -> (a, c) -> (b, c)
#
valuemapSnd :: (a -> b) -> (c, a) -> (c, b)
#
value(><) :: (a -> b) -> (c -> d) -> (a, c) -> (b, d)
#

Graph Transformer Monad

10 declarations
newtypenewtype GT (m :: Type -> Type) g a
#

Constructors

  • MGT (m g -> m (a, g))
Instances3Monad, Functor, Applicative
  • Monad m => Monad (GT m g)Defined in fgl-5.8.2.0 · Data.Graph.Inductive.Query.Monad
  • Monad m => Functor (GT m g)Defined in fgl-5.8.2.0 · Data.Graph.Inductive.Query.Monad
  • Monad m => Applicative (GT m g)Defined in fgl-5.8.2.0 · Data.Graph.Inductive.Query.Monad
valueapply :: GT m g a -> m g -> m (a, g)
#

Graph Computations Based on Graph Monads

0 declarations

Monadic Graph Accessing Functions

Derived Graph Recursion Operators

valuegraphRec
  1. :: GraphM m gr
  2. => GT m (gr a b) c
  3. -> c -> d -> d
  4. -> d
  5. -> GT m (gr a b) d
#

encapsulates a simple recursion schema on graphs

Examples: Graph Algorithms as Instances of Recursion Operators

0 declarations

Instances of graphRec

Example: Monadic DFS Algorithm(s)

6 declarations
valuedfsGT :: GraphM m gr => [Node] -> GT m (gr a b) [Node]
#

Monadic graph algorithms are defined in two steps:

  1. define the (possibly parameterized) graph transformer (e.g., dfsGT)

  2. run the graph transformer (applied to arguments) (e.g., dfsM)

valuedfsM :: GraphM m gr => [Node] -> m (gr a b) -> m [Node]
#

depth-first search yielding number of nodes