Skip to content

Instantly share code, notes, and snippets.

@jagajaga
Created May 21, 2015 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jagajaga/ae3557ff27e438d67b94 to your computer and use it in GitHub Desktop.
Save jagajaga/ae3557ff27e438d67b94 to your computer and use it in GitHub Desktop.
module Gshell.Graphs (
) where
import Control.Applicative
import Data.Graph.Inductive hiding (mkEdges, mkNodes)
import Data.GraphViz
import Data.GraphViz.Attributes
import Data.GraphViz.Attributes.Complete
import Data.GraphViz.Printing
import Data.Text.Lazy (Text, pack, unpack)
import Control.Lens
import Data.List
import Gshell.State
command :: String -> (Text, Shape)
command = flip (,) Circle . pack
content :: String -> (Text, Shape)
content = flip (,) BoxShape . pack
{-buildGraph :: GState -> Gr (Text, Shape) Text-}
{-buildGraph state = mkGraph nodes edges-}
{-where-}
{-nodes = mkNodes state-}
{-edges = mkEdges state-}
mkNodes state = result
where
result = zipWith (\a b -> (a, content $ state ^. revCommit b)) [1..] $ sortBy cmp $ state ^.. commitsRoot . traverse . _name
cmp rev1 rev2 = (state ^. timeStamp rev1) `compare` (state ^. timeStamp rev2)
mkEdges = mkEdges
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment