Generic instances for tuples, error recovery, show details when multiple solutions
This commit is contained in:
@@ -81,22 +81,9 @@ instance Ord Dir where
|
||||
instance Eq Dir where
|
||||
a == b = dirVal a == dirVal b
|
||||
|
||||
instance Eq DPoint where
|
||||
(a,b) == (c,d) = a == c && b == d
|
||||
|
||||
instance Ord DPoint where
|
||||
(a,b) < (c,d) = a < c || a == c && b < d
|
||||
|
||||
|
||||
Cand : U
|
||||
Cand = Int × Point × Dir
|
||||
|
||||
instance Eq Cand where
|
||||
(s,pt) == (s',pt') = s == s' && pt == pt'
|
||||
|
||||
instance Ord Cand where
|
||||
(s,pt) < (s',pt') = s < s' || s == s' && pt < pt'
|
||||
|
||||
min : Int → Int → Int
|
||||
min x y = if x < y then x else y
|
||||
|
||||
|
||||
@@ -24,18 +24,12 @@ instance Show Dir where
|
||||
show South = "S"
|
||||
show West = "W"
|
||||
|
||||
instance Eq Dir where
|
||||
a == b = show a == show b
|
||||
|
||||
instance Ord Dir where
|
||||
a < b = show a < show b
|
||||
|
||||
instance Eq (Point × Dir) where
|
||||
(a,b) == (c,d) = a == c && show b == show d
|
||||
|
||||
instance Ord (Point × Dir) where
|
||||
(a,b) < (c,d) =
|
||||
if a < c then True
|
||||
else if a /= c then False
|
||||
else b < d
|
||||
|
||||
Done : U
|
||||
Done = SortedMap (Point × Dir) Unit
|
||||
|
||||
|
||||
Reference in New Issue
Block a user