shithub: MicroHs

Download patch

ref: 35cc33cdee501af74eaf699d1f1a34c51f6b8ee1
parent: dd510e87456c2cd472f7759f0690bb762189c794
author: Lennart Augustsson <lennart@augustsson.net>
date: Mon Jan 6 06:07:44 EST 2025

Small improvement of anySame

--- a/src/MicroHs/List.hs
+++ b/src/MicroHs/List.hs
@@ -49,12 +49,8 @@
       [] -> "[]"
       a : as -> "[" ++ sa a ++ showRest as
 
-anySame :: (Eq a) => [a] -> Bool
-anySame = anySameBy (==)
-
-anySameBy :: (a -> a -> Bool) -> [a] -> Bool
-anySameBy _ [] = False
-anySameBy eq (x:xs) = elemBy eq x xs || anySameBy eq xs
+anySame :: (Ord a) => [a] -> Bool
+anySame = anySameByLE (<=)
 
 anySameByLE :: (a -> a -> Bool) -> [a] -> Bool
 anySameByLE le = anySameAdj . sortLE le
--- a/src/MicroHs/TypeCheck.hs
+++ b/src/MicroHs/TypeCheck.hs
@@ -2348,7 +2348,7 @@
 
 multCheck :: [Ident] -> T ()
 multCheck vs =
-  when (anySameByLE (<=) vs) $ do
+  when (anySame vs) $ do
     let v = head vs
     tcError (getSLoc v) $ "Multiply defined: " ++ showIdent v