Commit eefff9a1 authored by Sudhir Kumar's avatar Sudhir Kumar

added types for graph

parent ca5fe2f6
...@@ -39,18 +39,18 @@ derive instance newtypeGraphData :: Newtype GraphData _ ...@@ -39,18 +39,18 @@ derive instance newtypeGraphData :: Newtype GraphData _
instance decodeJsonGraphData :: DecodeJson GraphData where instance decodeJsonGraphData :: DecodeJson GraphData where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
nodes <- obj .? "nodes" nodes <- obj .? "graph_nodes"
edges <- obj .? "edges" edges <- obj .? "graph_edges"
pure $ GraphData { nodes, edges } pure $ GraphData { nodes, edges }
instance decodeJsonNode :: DecodeJson Node where instance decodeJsonNode :: DecodeJson Node where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
id_ <- obj .? "id" id_ <- obj .? "node_id"
type_ <- obj .? "type" type_ <- obj .? "node_type"
label <- obj .? "label" label <- obj .? "node_label"
size <- obj .? "size" size <- obj .? "node_size"
attributes <- obj .? "attributes" attributes <- obj .? "node_attributes"
pure $ Node { id_, type_, size, label, attributes } pure $ Node { id_, type_, size, label, attributes }
instance decodeJsonCluster :: DecodeJson Cluster where instance decodeJsonCluster :: DecodeJson Cluster where
...@@ -62,10 +62,10 @@ instance decodeJsonCluster :: DecodeJson Cluster where ...@@ -62,10 +62,10 @@ instance decodeJsonCluster :: DecodeJson Cluster where
instance decodeJsonEdge :: DecodeJson Edge where instance decodeJsonEdge :: DecodeJson Edge where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
id_ <- obj .? "id" id_ <- obj .? "edge_id"
source <- obj .? "source" source <- obj .? "edge_source"
target <- obj .? "target" target <- obj .? "edge_target"
weight <- obj .? "weight" weight <- obj .? "edge_weight"
pure $ Edge { id_, source, target, weight } pure $ Edge { id_, source, target, weight }
newtype Legend = Legend {id_ ::Int , label :: String} newtype Legend = Legend {id_ ::Int , label :: String}
...@@ -88,3 +88,5 @@ t' :: Node -> Legend ...@@ -88,3 +88,5 @@ t' :: Node -> Legend
t' (Node r) = Legend { id_ : clustDefault, label : r.label} t' (Node r) = Legend { id_ : clustDefault, label : r.label}
where where
(Cluster {clustDefault}) = r.attributes (Cluster {clustDefault}) = r.attributes
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment