{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses,
TypeSynonymInstances #-}
module Data.GraphViz.Types
( DotRepr(..)
, PrintDot(..)
, ParseDot(..)
, PrintDotRepr
, ParseDotRepr
, PPDotRepr
, GraphID(..)
, Number (..)
, ToGraphID(..)
, textGraphID
, GlobalAttributes(..)
, DotNode(..)
, DotEdge(..)
, ClusterLookup
, NodeLookup
, Path
, graphStructureInformationClean
, nodeInformationClean
, edgeInformationClean
, graphNodes
, graphEdges
, printDotGraph
, parseDotGraph
, parseDotGraphLiberally
) where
import Data.GraphViz.Attributes.Complete (rmUnwantedAttributes,
usedByClusters, usedByEdges,
usedByGraphs, usedByNodes)
import Data.GraphViz.Internal.State (GraphvizState)
import Data.GraphViz.Internal.Util (bool)
import Data.GraphViz.Parsing (ParseDot(..), adjustErr,
checkValidParseWithRest, parse,
parseLiberally, runParserWith)
import Data.GraphViz.PreProcessing (preProcess)
import Data.GraphViz.Printing (PrintDot(..), printIt)
import Data.GraphViz.Types.Canonical (DotGraph(..), DotStatements(..),
DotSubGraph(..))
import Data.GraphViz.Types.Internal.Common (DotEdge(..), DotNode(..),
GlobalAttributes(..), GraphID(..),
Number(..), numericValue, withGlob)
import Data.GraphViz.Types.State
import Control.Arrow (second, (***))
import Control.Monad.State (evalState, execState, get, modify, put)
import Data.Text.Lazy (Text)
import qualified Data.Text.Lazy as T
class (Ord n) => DotRepr dg n where
fromCanonical :: DotGraph n -> dg n
getID :: dg n -> Maybe GraphID
setID :: GraphID -> dg n -> dg n
graphIsDirected :: dg n -> Bool
setIsDirected :: Bool -> dg n -> dg n
graphIsStrict :: dg n -> Bool
setStrictness :: Bool -> dg n -> dg n
mapDotGraph :: (DotRepr dg n') => (n -> n') -> dg n -> dg n'
graphStructureInformation :: dg n -> (GlobalAttributes, ClusterLookup)
nodeInformation :: Bool -> dg n -> NodeLookup n
edgeInformation :: Bool -> dg n -> [DotEdge n]
unAnonymise :: dg n -> dg n
graphStructureInformationClean :: (DotRepr dg n) => dg n
-> (GlobalAttributes, ClusterLookup)
graphStructureInformationClean :: forall (dg :: * -> *) n.
DotRepr dg n =>
dg n -> (GlobalAttributes, ClusterLookup)
graphStructureInformationClean = (GlobalAttributes -> GlobalAttributes
globOnly forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second GlobalAttributes -> GlobalAttributes
clustOnly))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (dg :: * -> *) n.
DotRepr dg n =>
dg n -> (GlobalAttributes, ClusterLookup)
graphStructureInformation
where
globOnly :: GlobalAttributes -> GlobalAttributes
globOnly = (Attributes -> Attributes) -> GlobalAttributes -> GlobalAttributes
withGlob forall a b. (a -> b) -> a -> b
$ forall a. (a -> Bool) -> [a] -> [a]
filter Attribute -> Bool
usedByGraphs forall b c a. (b -> c) -> (a -> b) -> a -> c
. Attributes -> Attributes
rmUnwantedAttributes
clustOnly :: GlobalAttributes -> GlobalAttributes
clustOnly = (Attributes -> Attributes) -> GlobalAttributes -> GlobalAttributes
withGlob forall a b. (a -> b) -> a -> b
$ forall a. (a -> Bool) -> [a] -> [a]
filter Attribute -> Bool
usedByClusters forall b c a. (b -> c) -> (a -> b) -> a -> c
. Attributes -> Attributes
rmUnwantedAttributes
nodeInformationClean :: (DotRepr dg n) => Bool -> dg n -> NodeLookup n
nodeInformationClean :: forall (dg :: * -> *) n.
DotRepr dg n =>
Bool -> dg n -> NodeLookup n
nodeInformationClean = (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second Attributes -> Attributes
nodeOnly) forall b c a. (b -> c) -> (a -> b) -> a -> c
.) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (dg :: * -> *) n.
DotRepr dg n =>
Bool -> dg n -> NodeLookup n
nodeInformation
where
nodeOnly :: Attributes -> Attributes
nodeOnly = forall a. (a -> Bool) -> [a] -> [a]
filter Attribute -> Bool
usedByNodes forall b c a. (b -> c) -> (a -> b) -> a -> c
. Attributes -> Attributes
rmUnwantedAttributes
edgeInformationClean :: (DotRepr dg n) => Bool -> dg n -> [DotEdge n]
edgeInformationClean :: forall (dg :: * -> *) n.
DotRepr dg n =>
Bool -> dg n -> [DotEdge n]
edgeInformationClean = (forall a b. (a -> b) -> [a] -> [b]
map forall {n}. DotEdge n -> DotEdge n
rmEdgeAs forall b c a. (b -> c) -> (a -> b) -> a -> c
.) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (dg :: * -> *) n.
DotRepr dg n =>
Bool -> dg n -> [DotEdge n]
edgeInformation
where
rmEdgeAs :: DotEdge n -> DotEdge n
rmEdgeAs DotEdge n
de = DotEdge n
de { edgeAttributes :: Attributes
edgeAttributes = Attributes -> Attributes
edgeOnly forall a b. (a -> b) -> a -> b
$ forall n. DotEdge n -> Attributes
edgeAttributes DotEdge n
de }
edgeOnly :: Attributes -> Attributes
edgeOnly = forall a. (a -> Bool) -> [a] -> [a]
filter Attribute -> Bool
usedByEdges forall b c a. (b -> c) -> (a -> b) -> a -> c
. Attributes -> Attributes
rmUnwantedAttributes
class (DotRepr dg n, PrintDot (dg n)) => PrintDotRepr dg n
class (DotRepr dg n, ParseDot (dg n)) => ParseDotRepr dg n
class (PrintDotRepr dg n, ParseDotRepr dg n) => PPDotRepr dg n
graphNodes :: (DotRepr dg n) => dg n -> [DotNode n]
graphNodes :: forall (dg :: * -> *) n. DotRepr dg n => dg n -> [DotNode n]
graphNodes = forall n. NodeLookup n -> [DotNode n]
toDotNodes forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (dg :: * -> *) n.
DotRepr dg n =>
Bool -> dg n -> NodeLookup n
nodeInformation Bool
False
graphEdges :: (DotRepr dg n) => dg n -> [DotEdge n]
graphEdges :: forall (dg :: * -> *) n. DotRepr dg n => dg n -> [DotEdge n]
graphEdges = forall (dg :: * -> *) n.
DotRepr dg n =>
Bool -> dg n -> [DotEdge n]
edgeInformation Bool
False
printDotGraph :: (PrintDotRepr dg n) => dg n -> Text
printDotGraph :: forall (dg :: * -> *) n. PrintDotRepr dg n => dg n -> Text
printDotGraph = forall a. PrintDot a => a -> Text
printIt
parseDotGraph :: (ParseDotRepr dg n) => Text -> dg n
parseDotGraph :: forall (dg :: * -> *) n. ParseDotRepr dg n => Text -> dg n
parseDotGraph = forall (dg :: * -> *) n.
ParseDotRepr dg n =>
(GraphvizState -> GraphvizState) -> Text -> dg n
parseDotGraphWith forall a. a -> a
id
parseDotGraphLiberally :: (ParseDotRepr dg n) => Text -> dg n
parseDotGraphLiberally :: forall (dg :: * -> *) n. ParseDotRepr dg n => Text -> dg n
parseDotGraphLiberally = forall (dg :: * -> *) n.
ParseDotRepr dg n =>
(GraphvizState -> GraphvizState) -> Text -> dg n
parseDotGraphWith GraphvizState -> GraphvizState
parseLiberally
parseDotGraphWith :: (ParseDotRepr dg n) => (GraphvizState -> GraphvizState)
-> Text -> dg n
parseDotGraphWith :: forall (dg :: * -> *) n.
ParseDotRepr dg n =>
(GraphvizState -> GraphvizState) -> Text -> dg n
parseDotGraphWith GraphvizState -> GraphvizState
f = Text -> dg n
prs forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
preProcess
where
prs :: Text -> dg n
prs = forall a. (Either String a, Text) -> a
checkValidParseWithRest forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a.
(GraphvizState -> GraphvizState)
-> Parse a -> Text -> (Either String a, Text)
runParserWith GraphvizState -> GraphvizState
f Parser GraphvizState (dg n)
parse'
parse' :: Parser GraphvizState (dg n)
parse' = forall a. ParseDot a => Parse a
parse forall (p :: * -> *) a.
Commitment p =>
p a -> (String -> String) -> p a
`adjustErr`
(String
"Unable to parse the Dot graph; usually this is because of either:\n\
\ * Wrong choice of representation: try the Generalised one\n\
\ * Wrong choice of node type; try with `DotGraph String`.\n\
\\n\
\The actual parsing error was:\n\t"forall a. [a] -> [a] -> [a]
++)
instance (Ord n) => DotRepr DotGraph n where
fromCanonical :: DotGraph n -> DotGraph n
fromCanonical = forall a. a -> a
id
getID :: DotGraph n -> Maybe GraphID
getID = forall n. DotGraph n -> Maybe GraphID
graphID
setID :: GraphID -> DotGraph n -> DotGraph n
setID GraphID
i DotGraph n
g = DotGraph n
g { graphID :: Maybe GraphID
graphID = forall a. a -> Maybe a
Just GraphID
i }
graphIsDirected :: DotGraph n -> Bool
graphIsDirected = forall n. DotGraph n -> Bool
directedGraph
setIsDirected :: Bool -> DotGraph n -> DotGraph n
setIsDirected Bool
d DotGraph n
g = DotGraph n
g { directedGraph :: Bool
directedGraph = Bool
d }
graphIsStrict :: DotGraph n -> Bool
graphIsStrict = forall n. DotGraph n -> Bool
strictGraph
setStrictness :: Bool -> DotGraph n -> DotGraph n
setStrictness Bool
s DotGraph n
g = DotGraph n
g { strictGraph :: Bool
strictGraph = Bool
s }
mapDotGraph :: forall n'.
DotRepr DotGraph n' =>
(n -> n') -> DotGraph n -> DotGraph n'
mapDotGraph = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
graphStructureInformation :: DotGraph n -> (GlobalAttributes, ClusterLookup)
graphStructureInformation = forall a. GraphState a -> (GlobalAttributes, ClusterLookup)
getGraphInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall n. DotStatements n -> GraphState ()
statementStructure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall n. DotGraph n -> DotStatements n
graphStatements
nodeInformation :: Bool -> DotGraph n -> NodeLookup n
nodeInformation Bool
wGlobal = forall n a. Bool -> NodeState n a -> NodeLookup n
getNodeLookup Bool
wGlobal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall n. Ord n => DotStatements n -> NodeState n ()
statementNodes forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall n. DotGraph n -> DotStatements n
graphStatements
edgeInformation :: Bool -> DotGraph n -> [DotEdge n]
edgeInformation Bool
wGlobal = forall n a. Bool -> EdgeState n a -> [DotEdge n]
getDotEdges Bool
wGlobal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall n. DotStatements n -> EdgeState n ()
statementEdges forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall n. DotGraph n -> DotStatements n
graphStatements
unAnonymise :: DotGraph n -> DotGraph n
unAnonymise = forall n. DotGraph n -> DotGraph n
renumber
instance (Ord n, PrintDot n) => PrintDotRepr DotGraph n
instance (Ord n, ParseDot n) => ParseDotRepr DotGraph n
instance (Ord n, PrintDot n, ParseDot n) => PPDotRepr DotGraph n
statementStructure :: DotStatements n -> GraphState ()
statementStructure :: forall n. DotStatements n -> GraphState ()
statementStructure DotStatements n
stmts
= do forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ GlobalAttributes -> GraphState ()
addGraphGlobals forall a b. (a -> b) -> a -> b
$ forall n. DotStatements n -> [GlobalAttributes]
attrStmts DotStatements n
stmts
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (forall b a n.
(Maybe (Maybe GraphID) -> b -> a)
-> (DotStatements n -> b) -> DotSubGraph n -> a
withSubGraphID forall a. Maybe (Maybe GraphID) -> GraphState a -> GraphState ()
addSubGraph forall n. DotStatements n -> GraphState ()
statementStructure) forall a b. (a -> b) -> a -> b
$ forall n. DotStatements n -> [DotSubGraph n]
subGraphs DotStatements n
stmts
statementNodes :: (Ord n) => DotStatements n -> NodeState n ()
statementNodes :: forall n. Ord n => DotStatements n -> NodeState n ()
statementNodes DotStatements n
stmts
= do forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ forall n. GlobalAttributes -> NodeState n ()
addNodeGlobals forall a b. (a -> b) -> a -> b
$ forall n. DotStatements n -> [GlobalAttributes]
attrStmts DotStatements n
stmts
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (forall b a n.
(Maybe (Maybe GraphID) -> b -> a)
-> (DotStatements n -> b) -> DotSubGraph n -> a
withSubGraphID forall s. Maybe (Maybe GraphID) -> GVState s () -> GVState s ()
recursiveCall forall n. Ord n => DotStatements n -> NodeState n ()
statementNodes) forall a b. (a -> b) -> a -> b
$ forall n. DotStatements n -> [DotSubGraph n]
subGraphs DotStatements n
stmts
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ forall n. Ord n => DotNode n -> NodeState n ()
addNode forall a b. (a -> b) -> a -> b
$ forall n. DotStatements n -> [DotNode n]
nodeStmts DotStatements n
stmts
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ forall n. Ord n => DotEdge n -> NodeState n ()
addEdgeNodes forall a b. (a -> b) -> a -> b
$ forall n. DotStatements n -> [DotEdge n]
edgeStmts DotStatements n
stmts
statementEdges :: DotStatements n -> EdgeState n ()
statementEdges :: forall n. DotStatements n -> EdgeState n ()
statementEdges DotStatements n
stmts
= do forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ forall n. GlobalAttributes -> EdgeState n ()
addEdgeGlobals forall a b. (a -> b) -> a -> b
$ forall n. DotStatements n -> [GlobalAttributes]
attrStmts DotStatements n
stmts
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (forall b a n.
(Maybe (Maybe GraphID) -> b -> a)
-> (DotStatements n -> b) -> DotSubGraph n -> a
withSubGraphID forall s. Maybe (Maybe GraphID) -> GVState s () -> GVState s ()
recursiveCall forall n. DotStatements n -> EdgeState n ()
statementEdges) forall a b. (a -> b) -> a -> b
$ forall n. DotStatements n -> [DotSubGraph n]
subGraphs DotStatements n
stmts
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ forall n. DotEdge n -> EdgeState n ()
addEdge forall a b. (a -> b) -> a -> b
$ forall n. DotStatements n -> [DotEdge n]
edgeStmts DotStatements n
stmts
withSubGraphID :: (Maybe (Maybe GraphID) -> b -> a)
-> (DotStatements n -> b) -> DotSubGraph n -> a
withSubGraphID :: forall b a n.
(Maybe (Maybe GraphID) -> b -> a)
-> (DotStatements n -> b) -> DotSubGraph n -> a
withSubGraphID Maybe (Maybe GraphID) -> b -> a
f DotStatements n -> b
g DotSubGraph n
sg = Maybe (Maybe GraphID) -> b -> a
f Maybe (Maybe GraphID)
mid forall b c a. (b -> c) -> (a -> b) -> a -> c
. DotStatements n -> b
g forall a b. (a -> b) -> a -> b
$ forall n. DotSubGraph n -> DotStatements n
subGraphStmts DotSubGraph n
sg
where
mid :: Maybe (Maybe GraphID)
mid = forall a. a -> a -> Bool -> a
bool forall a. Maybe a
Nothing (forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall n. DotSubGraph n -> Maybe GraphID
subGraphID DotSubGraph n
sg) forall a b. (a -> b) -> a -> b
$ forall n. DotSubGraph n -> Bool
isCluster DotSubGraph n
sg
renumber :: DotGraph n -> DotGraph n
renumber :: forall n. DotGraph n -> DotGraph n
renumber DotGraph n
dg = DotGraph n
dg { graphStatements :: DotStatements n
graphStatements = DotStatements n
newStmts }
where
startN :: Int
startN = forall a. Enum a => a -> a
succ forall a b. (a -> b) -> a -> b
$ forall n. DotGraph n -> Int
maxSGInt DotGraph n
dg
newStmts :: DotStatements n
newStmts = forall s a. State s a -> s -> a
evalState (forall {m :: * -> *} {n}.
MonadState Int m =>
DotStatements n -> m (DotStatements n)
stRe forall a b. (a -> b) -> a -> b
$ forall n. DotGraph n -> DotStatements n
graphStatements DotGraph n
dg) Int
startN
stRe :: DotStatements n -> m (DotStatements n)
stRe DotStatements n
st = do [DotSubGraph n]
sgs' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM DotSubGraph n -> m (DotSubGraph n)
sgRe forall a b. (a -> b) -> a -> b
$ forall n. DotStatements n -> [DotSubGraph n]
subGraphs DotStatements n
st
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ DotStatements n
st { subGraphs :: [DotSubGraph n]
subGraphs = [DotSubGraph n]
sgs' }
sgRe :: DotSubGraph n -> m (DotSubGraph n)
sgRe DotSubGraph n
sg = do Maybe GraphID
sgid' <- case forall n. DotSubGraph n -> Maybe GraphID
subGraphID DotSubGraph n
sg of
Maybe GraphID
Nothing -> do Int
n <- forall s (m :: * -> *). MonadState s m => m s
get
forall s (m :: * -> *). MonadState s m => s -> m ()
put forall a b. (a -> b) -> a -> b
$ forall a. Enum a => a -> a
succ Int
n
forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. Number -> GraphID
Num forall a b. (a -> b) -> a -> b
$ Int -> Number
Int Int
n
Maybe GraphID
sgid -> forall (m :: * -> *) a. Monad m => a -> m a
return Maybe GraphID
sgid
DotStatements n
stmts' <- DotStatements n -> m (DotStatements n)
stRe forall a b. (a -> b) -> a -> b
$ forall n. DotSubGraph n -> DotStatements n
subGraphStmts DotSubGraph n
sg
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ DotSubGraph n
sg { subGraphID :: Maybe GraphID
subGraphID = Maybe GraphID
sgid'
, subGraphStmts :: DotStatements n
subGraphStmts = DotStatements n
stmts'
}
maxSGInt :: DotGraph n -> Int
maxSGInt :: forall n. DotGraph n -> Int
maxSGInt DotGraph n
dg = forall s a. State s a -> s -> s
execState (forall {n}. DotStatements n -> StateT Int Identity ()
stInt forall a b. (a -> b) -> a -> b
$ forall n. DotGraph n -> DotStatements n
graphStatements DotGraph n
dg)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe GraphID -> Int -> Int
`check` Int
0)
forall a b. (a -> b) -> a -> b
$ forall n. DotGraph n -> Maybe GraphID
graphID DotGraph n
dg
where
check :: Maybe GraphID -> Int -> Int
check = forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. a -> a
id forall a. Ord a => a -> a -> a
max forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GraphID -> Maybe Int
numericValue forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<)
stInt :: DotStatements n -> StateT Int Identity ()
stInt = forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ DotSubGraph n -> StateT Int Identity ()
sgInt forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall n. DotStatements n -> [DotSubGraph n]
subGraphs
sgInt :: DotSubGraph n -> StateT Int Identity ()
sgInt DotSubGraph n
sg = do forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (Maybe GraphID -> Int -> Int
check forall a b. (a -> b) -> a -> b
$ forall n. DotSubGraph n -> Maybe GraphID
subGraphID DotSubGraph n
sg)
DotStatements n -> StateT Int Identity ()
stInt forall a b. (a -> b) -> a -> b
$ forall n. DotSubGraph n -> DotStatements n
subGraphStmts DotSubGraph n
sg
class ToGraphID a where
toGraphID :: a -> GraphID
textGraphID :: Text -> GraphID
textGraphID :: Text -> GraphID
textGraphID = forall a. ToGraphID a => a -> GraphID
toGraphID
instance ToGraphID Text where
toGraphID :: Text -> GraphID
toGraphID = Text -> GraphID
Str
instance ToGraphID String where
toGraphID :: String -> GraphID
toGraphID = forall a. ToGraphID a => a -> GraphID
toGraphID forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack
instance ToGraphID Char where
toGraphID :: Char -> GraphID
toGraphID = forall a. ToGraphID a => a -> GraphID
toGraphID forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
T.singleton
instance ToGraphID Int where
toGraphID :: Int -> GraphID
toGraphID = Number -> GraphID
Num forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Number
Int
instance ToGraphID Integer where
toGraphID :: Integer -> GraphID
toGraphID = Number -> GraphID
Num forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Number
Int forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Num a => Integer -> a
fromInteger
instance ToGraphID Double where
toGraphID :: Double -> GraphID
toGraphID = Number -> GraphID
Num forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Number
Dbl