Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add symbol, symbols #298

Merged
merged 2 commits into from
Aug 15, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/Algebra/Graph/Label.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module Algebra.Graph.Label (
NonNegative, finite, finiteWord, unsafeFinite, infinite, getFinite,
Distance, distance, getDistance, Capacity, capacity, getCapacity,
Count, count, getCount, PowerSet (..), Minimum, getMinimum, noMinimum,
Path, Label, isZero, RegularExpression,
Path, Label, symbol, symbols, isZero, RegularExpression,

-- * Combining edge labels
Optimum (..), ShortestPath, AllShortestPaths, CountShortestPaths, WidestPath
Expand Down Expand Up @@ -377,6 +377,14 @@ data Label a = Zero
infixl 6 :+:
infixl 7 :*:

-- | Wrap a value into a 'Symbol' constructor
symbol :: a -> Label a
symbol = Symbol

-- | Wrap a list of values into 'Symbol' constructors terminated by 'Zero'
symbols :: Foldable t => t a -> Label a
symbols = foldr ((<>) . Symbol) Zero

instance IsList (Label a) where
type Item (Label a) = a
fromList = foldr ((<>) . Symbol) Zero
snowleopard marked this conversation as resolved.
Show resolved Hide resolved
Expand Down