on master help sign in
Use shorter names in UnionFind
1be6293Evan Czaplicki
src/Type/UnionFind.hs+12−13
@@ -3,13 +3,12 @@
3module Type.UnionFind
3module Type.UnionFind
4 ( Point
4 ( Point
5 , fresh
5 , fresh
6− , repr
7 , union
6 , union
8 , equivalent
7 , equivalent
9 , redundant
8 , redundant
10− , descriptor
9+ , get
11− , setDescriptor
10+ , set
12− , modifyDescriptor
11+ , modify
13 )
12 )
14 where
13 where
15
14
@@ -75,8 +74,8 @@ repr point@(Pt ref) =
75 return point2
74 return point2
76
75
77
76
78−descriptor :: Point a -> IO a
77+get :: Point a -> IO a
79−descriptor point@(Pt ref) =
78+get point@(Pt ref) =
80 do pInfo <- readIORef ref
79 do pInfo <- readIORef ref
81 case pInfo of
80 case pInfo of
82 Info _ descRef ->
81 Info _ descRef ->
@@ -89,11 +88,11 @@ descriptor point@(Pt ref) =
89 readIORef descRef
88 readIORef descRef
90
89
91 Link _ ->
90 Link _ ->
92− descriptor =<< repr point
91+ get =<< repr point
93
92
94
93
95−setDescriptor :: Point a -> a -> IO ()
94+set :: Point a -> a -> IO ()
96−setDescriptor point@(Pt ref) newDesc =
95+set point@(Pt ref) newDesc =
97 do pInfo <- readIORef ref
96 do pInfo <- readIORef ref
98 case pInfo of
97 case pInfo of
99 Info _ descRef ->
98 Info _ descRef ->
@@ -107,11 +106,11 @@ setDescriptor point@(Pt ref) newDesc =
107
106
108 Link _ ->
107 Link _ ->
109 do newPoint <- repr point
108 do newPoint <- repr point
110− setDescriptor newPoint newDesc
109+ set newPoint newDesc
111
110
112
111
113−modifyDescriptor :: Point a -> (a -> a) -> IO ()
112+modify :: Point a -> (a -> a) -> IO ()
114−modifyDescriptor point@(Pt ref) func =
113+modify point@(Pt ref) func =
115 do pInfo <- readIORef ref
114 do pInfo <- readIORef ref
116 case pInfo of
115 case pInfo of
117 Info _ descRef ->
116 Info _ descRef ->
@@ -125,7 +124,7 @@ modifyDescriptor point@(Pt ref) func =
125
124
126 Link _ ->
125 Link _ ->
127 do newPoint <- repr point
126 do newPoint <- repr point
128− modifyDescriptor newPoint func
127+ modify newPoint func
129
128
130
129
131union :: Point a -> Point a -> a -> IO ()
130union :: Point a -> Point a -> a -> IO ()