tungsten-0.1.0.0: Bring fusion to everyone

Copyright(c) Alexandre Moine 2019
Maintaineralexandre@moine.me
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Tungsten.Structure.Graph

Contents

Description

This module defines a type isomorphic to algebraic graphs (from A. Mokhov, see the algebraic-graphs package), in terms of Fix from Tungsten.Fix.

A good consumer is a function that can be fused with a good producer. A good producer is a function that can be fused with a good consumer.

Synopsis

Algebraic graphs as fixed-points

data GraphF a b Source #

The "factored-out" recursive type for algebraic graphs.

Constructors

EmptyF 
VertexF a 
OverlayF b b 
ConnectF b b 
Instances
Show2 GraphF Source # 
Instance details

Defined in Tungsten.Structure.Graph

Methods

liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> GraphF a b -> ShowS #

liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [GraphF a b] -> ShowS #

Functor (GraphF a) Source # 
Instance details

Defined in Tungsten.Structure.Graph

Methods

fmap :: (a0 -> b) -> GraphF a a0 -> GraphF a b #

(<$) :: a0 -> GraphF a b -> GraphF a a0 #

Show a => Show1 (GraphF a) Source # 
Instance details

Defined in Tungsten.Structure.Graph

Methods

liftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> GraphF a a0 -> ShowS #

liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [GraphF a a0] -> ShowS #

(Eq a, Eq b) => Eq (GraphF a b) Source # 
Instance details

Defined in Tungsten.Structure.Graph

Methods

(==) :: GraphF a b -> GraphF a b -> Bool #

(/=) :: GraphF a b -> GraphF a b -> Bool #

(Ord a, Ord b) => Ord (GraphF a b) Source # 
Instance details

Defined in Tungsten.Structure.Graph

Methods

compare :: GraphF a b -> GraphF a b -> Ordering #

(<) :: GraphF a b -> GraphF a b -> Bool #

(<=) :: GraphF a b -> GraphF a b -> Bool #

(>) :: GraphF a b -> GraphF a b -> Bool #

(>=) :: GraphF a b -> GraphF a b -> Bool #

max :: GraphF a b -> GraphF a b -> GraphF a b #

min :: GraphF a b -> GraphF a b -> GraphF a b #

(Read a, Read b) => Read (GraphF a b) Source # 
Instance details

Defined in Tungsten.Structure.Graph

(Show a, Show b) => Show (GraphF a b) Source # 
Instance details

Defined in Tungsten.Structure.Graph

Methods

showsPrec :: Int -> GraphF a b -> ShowS #

show :: GraphF a b -> String #

showList :: [GraphF a b] -> ShowS #

newtype Graph a Source #

Constructors

Graph (Fix (GraphF a)) 
Instances
Monad Graph Source # 
Instance details

Defined in Tungsten.Structure.Graph

Methods

(>>=) :: Graph a -> (a -> Graph b) -> Graph b #

(>>) :: Graph a -> Graph b -> Graph b #

return :: a -> Graph a #

fail :: String -> Graph a #

Functor Graph Source # 
Instance details

Defined in Tungsten.Structure.Graph

Methods

fmap :: (a -> b) -> Graph a -> Graph b #

(<$) :: a -> Graph b -> Graph a #

Applicative Graph Source # 
Instance details

Defined in Tungsten.Structure.Graph

Methods

pure :: a -> Graph a #

(<*>) :: Graph (a -> b) -> Graph a -> Graph b #

liftA2 :: (a -> b -> c) -> Graph a -> Graph b -> Graph c #

(*>) :: Graph a -> Graph b -> Graph b #

(<*) :: Graph a -> Graph b -> Graph a #

Show a => Show (Graph a) Source # 
Instance details

Defined in Tungsten.Structure.Graph

Methods

showsPrec :: Int -> Graph a -> ShowS #

show :: Graph a -> String #

showList :: [Graph a] -> ShowS #

empty :: Graph a Source #

The empty graph.

vertex :: a -> Graph a Source #

A vertex.

overlay :: Graph a -> Graph a -> Graph a Source #

Overlay two graphs.

connect :: Graph a -> Graph a -> Graph a Source #

Connect two graphs.

Classical operations on graphs

foldg Source #

Arguments

:: b

Empty case

-> (a -> b)

Vertex case

-> (b -> b -> b)

Overlay case

-> (b -> b -> b)

Connect case

-> Graph a

The graph to fold

-> b 

Fold a graph. Good consumer.

Operations on graphs

transpose :: Graph a -> Graph a Source #

Transpose a graph. Good consumer and good producer.

hasVertex :: Eq a => a -> Graph a -> Bool Source #

Test if a vertex is in a graph. Good consumer.

Conversions

vertices :: [a] -> Graph a Source #

Construct the graph comprising a given list of isolated vertices. Good consumer of lists and producer of graphs.

edges :: [(a, a)] -> Graph a Source #

Construct a graph from a list of edges Good consumer of lists and producer of graphs.