on master help sign in
Use shorter names in UnionFind

They will always be prefixed, so it is silly to follow that Haskell convention of repeating the context so it is nice when unqualified.

commit1be6293402cc82c53e40a6b8d27583ee1533c5ff authorEvan Czaplicki <evancz@users.noreply.github.com> dateFri 17 Nov 2017, 13:59 (9 years ago) parent1aa236a
1 file changed+12−13
src/Type/UnionFind.hs+12−13
src/Type/UnionFind.hs+12−13
@@ -3,13 +3,12 @@
33module Type.UnionFind
44 ( Point
55 , fresh
6− , repr
76 , union
87 , equivalent
98 , redundant
10− , descriptor
11− , setDescriptor
12− , modifyDescriptor
9+ , get
10+ , set
11+ , modify
1312 )
1413 where
1514
@@ -75,8 +74,8 @@ repr point@(Pt ref) =
7574 return point2
7675
7776
78−descriptor :: Point a -> IO a
79−descriptor point@(Pt ref) =
77+get :: Point a -> IO a
78+get point@(Pt ref) =
8079 do pInfo <- readIORef ref
8180 case pInfo of
8281 Info _ descRef ->
@@ -89,11 +88,11 @@ descriptor point@(Pt ref) =
8988 readIORef descRef
9089
9190 Link _ ->
92− descriptor =<< repr point
91+ get =<< repr point
9392
9493
95−setDescriptor :: Point a -> a -> IO ()
96−setDescriptor point@(Pt ref) newDesc =
94+set :: Point a -> a -> IO ()
95+set point@(Pt ref) newDesc =
9796 do pInfo <- readIORef ref
9897 case pInfo of
9998 Info _ descRef ->
@@ -107,11 +106,11 @@ setDescriptor point@(Pt ref) newDesc =
107106
108107 Link _ ->
109108 do newPoint <- repr point
110− setDescriptor newPoint newDesc
109+ set newPoint newDesc
111110
112111
113−modifyDescriptor :: Point a -> (a -> a) -> IO ()
114−modifyDescriptor point@(Pt ref) func =
112+modify :: Point a -> (a -> a) -> IO ()
113+modify point@(Pt ref) func =
115114 do pInfo <- readIORef ref
116115 case pInfo of
117116 Info _ descRef ->
@@ -125,7 +124,7 @@ modifyDescriptor point@(Pt ref) func =
125124
126125 Link _ ->
127126 do newPoint <- repr point
128− modifyDescriptor newPoint func
127+ modify newPoint func
129128
130129
131130union :: Point a -> Point a -> a -> IO ()