HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulealgebraic-graphs-0.8Haskell2010

Algebra.Graph.Internal

Alga is a library for algebraic construction and manipulation of graphs in Haskell. See this paper for the motivation behind the library, the underlying theory, and implementation details.

This module defines various internal utilities and data structures used throughout the library, such as lists with fast concatenation. The API is unstable and unsafe, and is exposed only for documentation.

  • 2 types
  • 13 values

Data structures

1 declaration
newtypenewtype List a
#

An abstract list data type with O(1) time concatenation (the current implementation uses difference lists). Here a is the type of list elements. List a is a Monoid: mempty corresponds to the empty list and two lists can be concatenated with mappend (or operator Data.Semigroup.<>). Singleton lists can be constructed using the function pure from the Applicative instance. List a is also an instance of IsList, therefore you can use list literals, e.g. [1,4] :: List Int is the same as pure 1 Data.Semigroup.<> pure 4; note that this requires the OverloadedLists GHC extension. To extract plain Haskell lists you can use the toList function from the Foldable instance.

Instances11Monad, Functor, Applicative, Foldable, IsList, Eq, …
  • Monad ListDefined in algebraic-graphs-0.8 · Algebra.Graph.Internal
  • Functor ListDefined in algebraic-graphs-0.8 · Algebra.Graph.Internal
  • Applicative ListDefined in algebraic-graphs-0.8 · Algebra.Graph.Internal
  • Foldable ListDefined in algebraic-graphs-0.8 · Algebra.Graph.Internal
  • IsList (List a)Defined in algebraic-graphs-0.8 · Algebra.Graph.Internal
  • Eq a => Eq (List a)Defined in algebraic-graphs-0.8 · Algebra.Graph.Internal
  • Ord a => Ord (List a)Defined in algebraic-graphs-0.8 · Algebra.Graph.Internal
  • Show a => Show (List a)Defined in algebraic-graphs-0.8 · Algebra.Graph.Internal
  • Semigroup (List a)Defined in algebraic-graphs-0.8 · Algebra.Graph.Internal
  • Monoid (List a)Defined in algebraic-graphs-0.8 · Algebra.Graph.Internal
  • type Item (List a) = aDefined in algebraic-graphs-0.8 · Algebra.Graph.Internal

Graph traversal

7 declarations
datadata Focus a
#

The focus of a graph expression is a flattened representation of the subgraph under focus, its context, as well as the list of all encountered vertices. See removeEdge for a use-case example.

Constructors

  • Focus
    • ok :: Bool

      True if focus on the specified subgraph is obtained.

    • is :: List a

      Inputs into the focused subgraph.

    • os :: List a

      Outputs out of the focused subgraph.

    • vs :: List a

      All vertices (leaves) of the graph expression.

valuevertexFocus :: (a -> Bool) -> a -> Focus a
#

Focus on the graph with a single vertex, given a predicate indicating whether the vertex is of interest.

valuemaybeF :: (a -> b -> a) -> a -> Maybe b -> Maybe a
#

An auxiliary function that tries to apply a function to a base case and a Maybe value and returns Just the result or Just the base case.

Utilities

7 declarations
valuecartesianProductWith :: Ord c => (a -> b -> c) -> Set a -> Set b -> Set c
#

Compute the Cartesian product of two sets, applying a function to each resulting pair.

valuecoerce00 :: Coercible f g => f x -> g x
#

Help GHC with type inference when direct use of coerce does not compile.