ref: 8093dbcceebfbb1872213c09abbb2bffb06492e3
parent: 3b3c5368c74d4d22a1073ad8cf44e574f8166a6a
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Fri Nov 3 15:36:40 EDT 2023
Generalize.
--- a/comb/mhs.comb
+++ b/comb/mhs.comb
@@ -1,3 +1,3 @@
v4.0
-1291
-((A :0 ((B (B (B (B C)))) ((B (B (B C))) ((B (B C)) P)))) ((A :1 (T (BK (BK (BK K))))) ((A :2 (T (K (BK (BK K))))) ((A :3 (T (K (K (BK K))))) ((A :4 (T (K (K (K K))))) ((A :5 (T (K (K (K A))))) ((A :6 (K (noDefault "Alternative.empty"))) ((A :7 (K (noDefault "Alternative.<|>"))) ((A :8 ((S (((S' S') ((B _14) _1)) (((C' _129) ((B _12) _1)) _302))) _5)) ((A :9 ((S (((S' C') _3) _4)) (((C' _13) _1) _301))) ((A :10 (((S' P) _2) (((C' _13) _1) _1049))) ((A :11 ((B (B (B (B C)))) ((B (B (B C))) ((B (B C)) P)))) ((A :12 (T (BK (BK (BK K))))) ((A :13 (T (K (BK (BK K))))) ((A :14 (T (K (K (BK K))))) ((A :15 (T (K (K (K K))))) ((A :16 (T (K (K (K A))))) ((A :17 (K (noDefault "Applicative.pure"))) ((A :18 (K (noDefault "Applicative.<*>"))) ((A :19 (((S' B) _14) (((C' _126) _12) _118))) ((A :20 (((S' B) _14) (((C' _129) _12) _119))) ((A :21 _1122) ((A :22 ((B _1165) _21)) ((A :23 (((S' _1165) _21) I)) ((A :24 _1092) ((A :25 (_24 "undefined")) ((A :26 I) ((A :27 (((C' B) _1121) ((C _117) _26))) ((A :28 (((C' _27) ((_125 _1135) _98)) ((_117 (_34 _1137)) _97))) ((A :29 ((B ((S _1165) (_34 _1137))) _24)) ((A :30 ((B (B (B C))) ((B (B C)) P))) ((A :31 (T (BK (BK K)))) ((A :32 (T (K (BK K)))) ((A :33 (T (K (K K)))) ((A :34 (T (K (K A)))) ((A :35 (K (noDefault "Monad.>>="))) ((A :36 (((C' (C' B)) _32) K)) ((A :37 ((B _13) _31)) ((A :38 (((S' (C' B)) _32) (((S' (C' B)) _32) (B' _34)))) ((A :39 P) ((A :40 (T K)) ((A :41 (T A)) ((A :42 (K _24)) ((A :43 ((B (B Y)) (((S' B) (B' ((B P) ((C _34) _301)))) (((S' (C' B)) ((B (B (C' B))) (B' _32))) (((S' (C' (C' B))) (B' _32)) (((C' B) (B' _34)) _302)))))) ((A :44 ((B (B Y)) (((S' B) (B' ((B P) ((C _34) _1049)))) (((C' (C' B)) ((B (B (C' B))) (B' _32))) BK)))) ((A :45 ((B T) ((C _34) _1049))) ((A :46 ((C _43) _118)) ((A :47 ((B _120) _32)) ((A :48 ((B C) ((B C') _32))) ((A :49 ((B _120) _48)) ((A :50 T) ((A :51 ((_124 ((B (B (_115 _50))) ((B ((C' C) _54)) (B P)))) (_128 _51))) ((A :52 (((((_11 _51) ((B (_115 _50)) P)) (_38 _53)) ((B (B (_115 _50))) (((C' B) ((B C) _54)) (BK _54)))) (_20 _52))) ((A :53 ((((_30 _52) ((B (B (_115 _50))) (((C' B) ((B C) _54)) (B _54)))) (_15 _52)) (_13 _52))) ((A :54 (T I)) ((A :55 ((B (_117 _357)) _54)) ((A :56 ((B (_115 _50)) (B (P _1049)))) ((A :57 ((B (_115 _50)) (BK (P _1049)))) ((A :58 ((_115 _50) ((S P) I))) ((A :59 ((B (_115 _50)) ((C (S' P)) I))) ((A :60 ((_102 ((C ((C S') _65)) I)) (_106 _60))) ((A :61 (((_1263 (K ((P (_1272 "False")) (_1272 "True")))) (_1268 _61)) (_1269 _61))) ((A :62 ((_69 _67) _68)) ((A :63 (R _68)) ((A :64 (T _67)) ((A :65 ((P _68) _67)) ((A :66 _68) ((A :67 K) ((A :68 A) ((A :69 P) ((A :70 (T K)) ((A :71 (T A)) ((A :72 (K (noDefault "Bounded.minBound"))) ((A :73 (K (noDefault "Bounded.maxBound"))) ((A :74 ((_102 _1086) _1087)) ((A :75 ((((((((_334 _74) (_343 _75)) _1088) _1089) _1090) _1091) (_348 _75)) (_349 _75))) ((A :76 ((_102 _1096) (_106 _76))) ((A :77 ((((((((_334 _76) _1095) (((C' (C' (_103 _350))) _1095) _354)) (((C' (C' (_104 _350))) _1095) _356)) (((C' (C' (_103 _350))) _1095) _356)) (((C' (C' (_104 _350))) _1095) _356)) (_348 _77)) (_349 _77))) ((A :78 ((_69 (_79 #0)) (_79 #127))) ((A :79 _1097) ((A :80 _1098) ((A :81 (((S' _64) (_1089 #97)) ((C _1089) #122))) ((A :82 (((S' _64) (_1089 #65)) ((C _1089) #90))) ((A :83 (((S' _63) _81) _82)) ((A :84 (((S' _64) (_1089 #48)) ((C _1089) #57))) ((A :85 (((S' _63) _83) _84)) ((A :86 (((S' _64) (_1089 #32)) ((C _1089) #126))) ((A :87 (((S' _63) ((C (_103 _74)) #32)) (((S' _63) ((C (_103 _74)) #9)) ((C (_103 _74)) #10)))) ((A :88 ((S ((S (((S' _64) (_1089 #65)) ((C _1089) #90))) (_68 (((noMatch "lib/Data/Char.hs") #72) #9)))) ((B _79) (((C' (_319 _130)) (((C' (_320 _130)) _80) (_80 #65))) (_80 #97))))) ((A :89 ((S ((S (((S' _64) (_1089 #97)) ((C _1089) #97))) (_68 (((noMatch "lib/Data/Char.hs") #76) #9)))) ((B _79) (((C' (_319 _130)) (((C' (_320 _130)) _80) (_80 #97))) (_80 #65))))) ((A :90 (((_1263 (K ((C ((S ((C ==) #39)) ((B (_117 (_1271 #39))) (((C' _117) ((B _1272) _91)) (_1271 #39))))) (_1272 "'\92&''")))) (_1268 _90)) ((B (_117 (_1271 #34))) (Y ((B (P (_1271 #34))) (((S' C) ((B
\ No newline at end of file
+1293
+((A :0 ((B (B (B (B C)))) ((B (B (B C))) ((B (B C)) P)))) ((A :1 (T (BK (BK (BK K))))) ((A :2 (T (K (BK (BK K))))) ((A :3 (T (K (K (BK K))))) ((A :4 (T (K (K (K K))))) ((A :5 (T (K (K (K A))))) ((A :6 (K (noDefault "Alternative.empty"))) ((A :7 (K (noDefault "Alternative.<|>"))) ((A :8 ((S (((S' S') ((B _14) _1)) (((C' _129) ((B _12) _1)) _304))) _5)) ((A :9 ((S (((S' C') _3) _4)) (((C' _13) _1) _303))) ((A :10 (((S' P) _2) (((C' _13) _1) _1051))) ((A :11 ((B (B (B (B C)))) ((B (B (B C))) ((B (B C)) P)))) ((A :12 (T (BK (BK (BK K))))) ((A :13 (T (K (BK (BK K))))) ((A :14 (T (K (K (BK K))))) ((A :15 (T (K (K (K K))))) ((A :16 (T (K (K (K A))))) ((A :17 (K (noDefault "Applicative.pure"))) ((A :18 (K (noDefault "Applicative.<*>"))) ((A :19 (((S' B) _14) (((C' _126) _12) _118))) ((A :20 (((S' B) _14) (((C' _129) _12) _119))) ((A :21 _1124) ((A :22 ((B _1167) _21)) ((A :23 (((S' _1167) _21) I)) ((A :24 _1094) ((A :25 (_24 "undefined")) ((A :26 I) ((A :27 (((C' B) _1123) ((C _117) _26))) ((A :28 (((C' _27) ((_125 _1137) _98)) ((_117 (_34 _1139)) _97))) ((A :29 ((B ((S _1167) (_34 _1139))) _24)) ((A :30 ((B (B (B C))) ((B (B C)) P))) ((A :31 (T (BK (BK K)))) ((A :32 (T (K (BK K)))) ((A :33 (T (K (K K)))) ((A :34 (T (K (K A)))) ((A :35 (K (noDefault "Monad.>>="))) ((A :36 (((C' (C' B)) _32) K)) ((A :37 ((B _13) _31)) ((A :38 (((S' (C' B)) _32) (((S' (C' B)) _32) (B' _34)))) ((A :39 P) ((A :40 (T K)) ((A :41 (T A)) ((A :42 (K _24)) ((A :43 ((B (B Y)) (((S' B) (B' ((B P) ((C _34) _303)))) (((S' (C' B)) ((B (B (C' B))) (B' _32))) (((S' (C' (C' B))) (B' _32)) (((C' B) (B' _34)) _304)))))) ((A :44 ((B (B Y)) (((S' B) (B' ((B P) ((C _34) _1051)))) (((C' (C' B)) ((B (B (C' B))) (B' _32))) BK)))) ((A :45 ((B T) ((C _34) _1051))) ((A :46 ((C _43) _118)) ((A :47 ((B _120) _32)) ((A :48 ((B C) ((B C') _32))) ((A :49 ((B _120) _48)) ((A :50 T) ((A :51 ((_124 ((B (B (_115 _50))) ((B ((C' C) _54)) (B P)))) (_128 _51))) ((A :52 (((((_11 _51) ((B (_115 _50)) P)) (_38 _53)) ((B (B (_115 _50))) (((C' B) ((B C) _54)) (BK _54)))) (_20 _52))) ((A :53 ((((_30 _52) ((B (B (_115 _50))) (((C' B) ((B C) _54)) (B _54)))) (_15 _52)) (_13 _52))) ((A :54 (T I)) ((A :55 ((B (_117 _359)) _54)) ((A :56 ((B (_115 _50)) (B (P _1051)))) ((A :57 ((B (_115 _50)) (BK (P _1051)))) ((A :58 ((_115 _50) ((S P) I))) ((A :59 ((B (_115 _50)) ((C (S' P)) I))) ((A :60 ((_102 ((C ((C S') _65)) I)) (_106 _60))) ((A :61 (((_1265 (K ((P (_1274 "False")) (_1274 "True")))) (_1270 _61)) (_1271 _61))) ((A :62 ((_69 _67) _68)) ((A :63 (R _68)) ((A :64 (T _67)) ((A :65 ((P _68) _67)) ((A :66 _68) ((A :67 K) ((A :68 A) ((A :69 P) ((A :70 (T K)) ((A :71 (T A)) ((A :72 (K (noDefault "Bounded.minBound"))) ((A :73 (K (noDefault "Bounded.maxBound"))) ((A :74 ((_102 _1088) _1089)) ((A :75 ((((((((_336 _74) (_345 _75)) _1090) _1091) _1092) _1093) (_350 _75)) (_351 _75))) ((A :76 ((_102 _1098) (_106 _76))) ((A :77 ((((((((_336 _76) _1097) (((C' (C' (_103 _352))) _1097) _356)) (((C' (C' (_104 _352))) _1097) _358)) (((C' (C' (_103 _352))) _1097) _358)) (((C' (C' (_104 _352))) _1097) _358)) (_350 _77)) (_351 _77))) ((A :78 ((_69 (_79 #0)) (_79 #127))) ((A :79 _1099) ((A :80 _1100) ((A :81 (((S' _64) (_1091 #97)) ((C _1091) #122))) ((A :82 (((S' _64) (_1091 #65)) ((C _1091) #90))) ((A :83 (((S' _63) _81) _82)) ((A :84 (((S' _64) (_1091 #48)) ((C _1091) #57))) ((A :85 (((S' _63) _83) _84)) ((A :86 (((S' _64) (_1091 #32)) ((C _1091) #126))) ((A :87 (((S' _63) ((C (_103 _74)) #32)) (((S' _63) ((C (_103 _74)) #9)) ((C (_103 _74)) #10)))) ((A :88 ((S ((S (((S' _64) (_1091 #65)) ((C _1091) #90))) (_68 (((noMatch "lib/Data/Char.hs") #72) #9)))) ((B _79) (((C' (_321 _130)) (((C' (_322 _130)) _80) (_80 #65))) (_80 #97))))) ((A :89 ((S ((S (((S' _64) (_1091 #97)) ((C _1091) #97))) (_68 (((noMatch "lib/Data/Char.hs") #76) #9)))) ((B _79) (((C' (_321 _130)) (((C' (_322 _130)) _80) (_80 #97))) (_80 #65))))) ((A :90 (((_1265 (K ((C ((S ((C ==) #39)) ((B (_117 (_1273 #39))) (((C' _117) ((B _1274) _91)) (_1273 #39))))) (_1274 "'\92&''")))) (_1270 _90)) ((B (_117 (_1273 #34))) (Y ((B (P (_1273 #34))) (((S' C) ((B
\ No newline at end of file
--- a/lib/Data/Int.hs
+++ b/lib/Data/Int.hs
@@ -39,30 +39,10 @@
--------------------------------
--- infix 4 ==,/=
---infix 4 <,<=,>,>=
-
--- Comparison
-{--(==) :: Int -> Int -> Bool
-(==) = primIntEQ
-(/=) :: Int -> Int -> Bool
-(/=) = primIntNE
--}
instance Eq Int where
(==) = primIntEQ
(/=) = primIntNE
-{--(<) :: Int -> Int -> Bool
-(<) = primIntLT
-(<=) :: Int -> Int -> Bool
-(<=) = primIntLE
-(>) :: Int -> Int -> Bool
-(>) = primIntGT
-(>=) :: Int -> Int -> Bool
-(>=) = primIntGE
--}
instance Ord Int where
(<) = primIntLT
(<=) = primIntLE
--- a/lib/Data/List.hs
+++ b/lib/Data/List.hs
@@ -86,16 +86,20 @@
foldl1 _ [] = error "foldl1"
foldl1 f (x : xs) = foldl f x xs
-minimum :: [Int] -> Int
+minimum :: forall a . Ord a => [a] -> a
minimum [] = error "minimum"
minimum (x:ys) = foldr (\ y m -> if y < m then y else m) x ys
-sum :: [Int] -> Int
-sum = foldr (+) (0::Int)
+maximum :: forall a . Ord a => [a] -> a
+maximum [] = error "maximum"
+maximum (x:ys) = foldr (\ y m -> if y > m then y else m) x ys
-product :: [Int] -> Int
-product = foldr (*) (1::Int)
+sum :: forall a . Num a => [a] -> a
+sum = foldr (+) 0
+product :: forall a . Num a => [a] -> a
+product = foldr (*) 1
+
and :: [Bool] -> Bool
and = foldr (&&) True
@@ -336,6 +340,9 @@
partition :: forall a . (a -> Bool) -> [a] -> ([a], [a])
partition p xs = (filter p xs, filter (not . p) xs)
+
+sort :: forall a . Ord a => [a] -> [a]
+sort = sortLE (<=)
-- A simple "quicksort" for now.
sortLE :: forall a . (a -> a -> Bool) -> [a] -> [a]
--- a/tests/ListTest.hs
+++ b/tests/ListTest.hs
@@ -3,7 +3,7 @@
main :: IO ()
main = do
- putStrLn $ show $ sum [1,2,3]
- putStrLn $ show $ product [1,2,3,4]
+ putStrLn $ show $ sum [1,2,3::Int]
+ putStrLn $ show $ product [1,2,3,4::Int]
putStrLn $ show $ and [True]
putStrLn $ show $ and [True, False]
--
⑨