Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 1.19 KB

dot.md

File metadata and controls

41 lines (29 loc) · 1.19 KB

Dot

A dot file can be extracted from a registry, showing the dependencies between elements. You can then display it online with such a website:

The graph above was produced with the following code

-- create a DOT representation of the graph for "IO Listener"
makeDot @(IO Listener) registry

config =
     valTo @IO (AuthConfig "auth")
  <: valTo @IO (ListenerConfig "nyc")

registry =
     funTo @IO newListener
  <: funTo @IO newAuth
  <: fun       newLogging

-- A small graph of components

newtype Logging = Logging { info :: Text -> IO () }

newLogging :: IO Logging
newLogging = pure (Logging print)

newtype Auth = Auth { auth :: Text -> IO Bool }
newtype AuthConfig = AuthConfig Text deriving (Eq, Show)

newAuth :: AuthConfig -> Logging -> Auth
newAuth _config _logging = Auth (\t -> print t >> pure True)

newtype Listener = Listener { listen :: Text -> IO () }
newtype ListenerConfig = ListenerConfig Text deriving (Eq, Show)

newListener :: ListenerConfig -> Logging -> IO Listener
newListener _config _logging = pure (Listener print)