module GHC.Vis.Types (
Point,
DrawFunction,
Signal(..),
View(..),
ViewType(..),
State(..),
HeapEntry,
HeapMap,
PState(..),
PrintState,
VisObject(..)
)
where
import GHC.HeapView
import qualified Control.Monad.State as MS
import Graphics.UI.Gtk hiding (Box, Signal, Point)
import Graphics.Rendering.Cairo
type Point = (Double, Double)
type DrawFunction = forall a. FilePath -> Double -> Double -> (Surface -> IO a) -> IO a
data Signal = NewSignal Box String
| UpdateSignal
| ClearSignal
| SwitchSignal
| ExportSignal DrawFunction String
data View = View
{ redraw :: WidgetClass w => w -> IO ()
, click :: IO ()
, move :: WidgetClass w => w -> IO ()
, updateObjects :: [(Box, String)] -> IO ()
, exportView :: DrawFunction -> String -> IO ()
}
data ViewType = ListView
| GraphView
deriving (Enum)
data State = State
{ mousePos :: Point
, view :: ViewType
, zoomRatio :: Double
, position :: Point
, dragging :: Bool
, wasDragged :: Bool
}
type HeapEntry =
( Maybe String
, Closure
)
type HeapMap = [(Box, HeapEntry)]
data PState = PState
{ tCounter :: Integer
, fCounter :: Integer
, bCounter :: Integer
, heapMap :: HeapMap
, heapMap' :: HeapMap
}
type PrintState = MS.State PState
data VisObject = Unnamed String
| Named String [VisObject]
| Link String
| Thunk String
| Function String
deriving Eq
instance Show VisObject where
show (Unnamed x) = x
show (Named x ys) = x ++ "=(" ++ show ys ++ ")"
show (Link x) = x
show (Thunk x) = x
show (Function x) = x
showList = foldr ((.) . showString . show) (showString "")