File tree 2 files changed +19
-11
lines changed
2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -11,21 +11,29 @@ Example
11
11
---
12
12
13
13
``` purescript
14
+ -- your data type
15
+ data Tree' a = Leaf' | Node' (Tree' a) a (Tree' a)
14
16
15
- newtype User = User {name :: String, age :: Int, friends :: Test}
17
+ -- derive generic
18
+ derive instance treeGeneric :: Generic (Tree' a) _
16
19
17
- derive instance genericUser :: Generic User _
20
+ -- create instances for the needed type classes
21
+ instance treeEdges :: Edges a => Edges (Tree' a) where edges x = genericEdges x
22
+ instance treeDotRepr :: Edges a => GraphRepr (Tree' a) where toGraph = genericToGraph
18
23
19
- instance egdeUser :: Edges User where
20
- edges = genericEdges
24
+ example :: String
25
+ example = renderToSvg Dot $ toGraph $
26
+ Node' Leaf' 3 (Node' (Node' Leaf' 5 Leaf') 4 Leaf')
27
+ -- example = "...<svg><g>...</g>...</svg>..."
28
+ ```
21
29
22
- instance graphReprUser :: GraphRepr User where
23
- toDot = genericToDot
30
+ ![ screenshot] ( screenshot.png )
24
31
25
- generateSvg :: ∀a. GraphRepr a => a -> String
26
- generateSvg e = renderToSvg Dot e
32
+ see [ full file] ( ./test/Example.purs ) for imports
27
33
28
- example = generateSvg (User {name: "Test", age: 2, friends: R A A B})
29
- ```
34
+ TODOs
35
+ -----
30
36
31
- ![ screenshot] ( screenshot.png )
37
+ - Refactor into multiple libraries
38
+ - support entine DOT language in data model
39
+ - allow custom edges in GenericGraph
You can’t perform that action at this time.
0 commit comments