ref: dd6d15f672fd622dbca510bd562d66c629bca6a3
parent: 3181efc342bee2b68ca4d2a01da1e1ded8bc2bd4
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Wed Sep 20 07:19:00 EDT 2023
Get rid of 'pair'
--- a/comb/mhs.comb
+++ b/comb/mhs.comb
@@ -1,3 +1,3 @@
v3.4
-851
-(($A :0 ((_645 _594) (($B ((($S' ($C ((($C' ($S' _645)) (($B ($C _2)) _577)) (($B ($B (_645 _674))) ((($C' ($C' $C)) ((($C' ($S' ($C' $C))) ((($C' ($C' ($C' $C))) ((($C' ($C' ($C' ($C' $S')))) (($B ($B ($B ($B $C)))) ((($C' ($C' ($C' $B))) (($B ($B ($B ($C' $S)))) ((($C' ($C' ($C' ($C' $C)))) ((($C' ($C' ($C' ($C' ($C' $S'))))) (($B ($B ($B ($B ($B $C))))) ((($C' ($C' ($C' ($C' ($C' $C))))) ((($C' ($C' ($C' $B))) (($B ($B ($B ($C' ($C' $S'))))) ((($C' ($C' ($C' ($C' ($C' $C'))))) ((($C' ($C' ($C' ($S' ($C' $C'))))) (($B ($B ($B ($B $B')))) ((($S' $B) ($B' ($B' (($B ($S' $B)) (($B ($B _646)) ((($C' $B) (($B _743) (($B _664) ((($C' _780) _9) 0)))) (($B (_743 _667)) (($B (_680 "top level defns: ")) _625)))))))) ((($S' $B) ($B' (($B ($C' $B)) (($B $B') (($B ($B _646)) ((($C' $B) (($B _743) (($B _664) ((($C' _780) _9) 1)))) (_663 ($T (($B ($B (_743 _667))) ((($C' $B) (($B _680) ((($C' _680) _583) " = "))) (($C _402) $K))))))))))) ((($C' $B) ((($S' $C') (($B $C') (($B $C') _10))) ((($S' $B) (($B ($C' ($C' _646))) ((($C' $B) ($B' (($B _743) (($B _669) _12)))) (($B _680) ((($C' _680) (($B (_680 _1)) _625)) (($O 10) $K)))))) (($B ($B (_645 _674))) ((($C' $B) ($B' (($B _743) (($B _664) ((($C' _780) _9) 0))))) (($B ($B (_743 _667))) ((($C' ($C' _680)) (($B ($B (_680 "final pass "))) (($B ($B (_639 6))) (($B ($B _625)) _774)))) "ms"))))))) _3))))) ((($C' ($C' $C)) (($B (($C' $C) (($B ($C _685)) _402))) (($C _698) (_714 0)))) $K))) (($B ($C $B)) (($B ($B ($C $B))) (($B ($B $BK)) (($B ($B (($C' $B) (($B _744) (($B _680) ((($C' _680) (($B (_680 "(($A :")) _625)) (($O 32) $K))))))) ((($C' $B) (($B ($C' _744)) ($B _402))) (($B (_744 (_680 ") "))) (($C _744) (_680 (($O 41) $K)))))))))))) $T)) (($B $Y) ((($C' ($C' $S)) ((($C' ($C' $S)) ((($C' $B) $P) ((($S' ($C' $B)) ($B _377)) $I))) ($BK $K))) $K))))) (($B (($S' _743) (($B _740) (($B (_743 _789)) (($B (_680 "main: findIdent: ")) _583))))) (($C' _613) _580)))) _620))) (($B ($B _617)) ((($C' $B) (($B _682) (($B $T) (($B ($C $B)) (($B ($B $BK)) ((($C' ($C' ($C' $O))) ($B (($C' $P) _580))) $K)))))) (($C _698) (_714 0))))))) ($T $A))) ($T $K))) $I)) (($B (_743 _376)) (($B (_743 _577)) (($B (_680 (($O 95) $K))) _625)))))))) (($S (($S ((($S' _8) (($B _697) (_684 (_637 "-v")))) ((_713 _637) "-r"))) (($B (_678 (($O 46) $K))) (($B _742) (_683 ((_702 _765) "-i")))))) (($B (_743 _709)) ((($C' _680) (($B _742) (_683 ((_702 _765) "-o")))) (($O "out.comb") $K))))) (($B (($S (($C ((($C' _776) _697) 1)) (_789 "Usage: mhs [-v] [-r] [-iPATH] [-oFILE] ModuleName"))) _709)) (_684 ((_744 _785) ((_744 (_637 (($O 45) $K))) (_695 1))))))) (_705 ((_744 _785) (_637 "--")))))) (($A :1 "v3.4\10&") (($A :2 ((($S' ($S' _645)) _17) (($B ($B ($B (_645 _674)))) ((($C' ($C' $B)) (($B ($B ($C' (($S' _645) (($B _647) (_736 _222)))))) (($B ($B ($B ($B $T)))) (($B ($B ($B ($B (_645 _674))))) ((($C' $B) (($B ($C' $B)) (($B ($B ($C' _646))) ((($C' $B) ($B' (($B _743) (($B _664) ((($C' _780) _9) 0))))) (($B ($B (_743 _667))) ((($C' ($C' _680)) (($B ($B (_680 "combinator conversion "))) (($B ($B (_639 6))) (($B ($B _625)) _774)))) "ms")))))) (($B ($B _647)) (($B $P) (($C _586) (_577 "main"))))))))) (_682 ($T ((($C' ($C' $O)) ((($C' $B) $P) _405)) $K))))))) (($A :3 (($B (_645 _594)) (($B (($C' _595) ((($C' _769) (($B _697) (_705 ((_744 _785) (_637 "--"))))) 1))) (($B (_743 _7)) _4)))) (($A :4 ($T (($C ((($C' $C') (($B $S) ($C $C))) (($B ($B $Y)) (($B ($B ($B _567))) (($C' ($C' _682)) (($B ($B $T)) ((($C' ($C' ($C' ($C' $O)))) (($B ($B (($C' $B) $P))) ($B _5))) $K))))))) (($B (($S' _743) (($B _740) (($B (_743 _789)) (($B (_680 "not found ")) _583))))) ($C _568))))) (($A :5 ((($C' $C) ((($S' $C) ((($C' ($C' $S')) (($S $P) ((($S' ($C' $B)) (($B ($B _7)) _5)) _5))) ($BK $K))) ((($C' ($S' $C)) ((($C' ($C' $C)) (($B (($C' $C) (($B ($P _7)) $K))) ((($C' $B) _5) _404))) ((($S' _743) (($B _740) (($B (_743 _789)) (_680 "primlookup: ")))) (($C (_719 _637)) _6)))) $K))) (_789 "trans: impossible"))) (($A :6 (($O (($P (($O 66) $K)) $B)) (($O (($P (($O 79) $K)) $O)) (($O (($P (($O 75) $K)) $K)) (($O (($P "C'") $C')) (($O (($P (($O 67)
\ No newline at end of file
+850
+(($A :0 ((_645 _594) (($B ((($S' ($C ((($C' ($S' _645)) (($B ($C _2)) _577)) (($B ($B (_645 _674))) ((($C' ($C' $C)) ((($C' ($S' ($C' $C))) ((($C' ($C' ($C' $C))) ((($C' ($C' ($C' ($C' $S')))) (($B ($B ($B ($B $C)))) ((($C' ($C' ($C' $B))) (($B ($B ($B ($C' $S)))) ((($C' ($C' ($C' ($C' $C)))) ((($C' ($C' ($C' ($C' ($C' $S'))))) (($B ($B ($B ($B ($B $C))))) ((($C' ($C' ($C' ($C' ($C' $C))))) ((($C' ($C' ($C' $B))) (($B ($B ($B ($C' ($C' $S'))))) ((($C' ($C' ($C' ($C' ($C' $C'))))) ((($C' ($C' ($C' ($S' ($C' $C'))))) (($B ($B ($B ($B $B')))) ((($S' $B) ($B' ($B' (($B ($S' $B)) (($B ($B _646)) ((($C' $B) (($B _743) (($B _664) ((($C' _779) _9) 0)))) (($B (_743 _667)) (($B (_680 "top level defns: ")) _625)))))))) ((($S' $B) ($B' (($B ($C' $B)) (($B $B') (($B ($B _646)) ((($C' $B) (($B _743) (($B _664) ((($C' _779) _9) 1)))) (_663 ($T (($B ($B (_743 _667))) ((($C' $B) (($B _680) ((($C' _680) _583) " = "))) (($C _402) $K))))))))))) ((($C' $B) ((($S' $C') (($B $C') (($B $C') _10))) ((($S' $B) (($B ($C' ($C' _646))) ((($C' $B) ($B' (($B _743) (($B _669) _12)))) (($B _680) ((($C' _680) (($B (_680 _1)) _625)) (($O 10) $K)))))) (($B ($B (_645 _674))) ((($C' $B) ($B' (($B _743) (($B _664) ((($C' _779) _9) 0))))) (($B ($B (_743 _667))) ((($C' ($C' _680)) (($B ($B (_680 "final pass "))) (($B ($B (_639 6))) (($B ($B _625)) _773)))) "ms"))))))) _3))))) ((($C' ($C' $C)) (($B (($C' $C) (($B ($C _685)) _402))) (($C _698) (_714 0)))) $K))) (($B ($C $B)) (($B ($B ($C $B))) (($B ($B $BK)) (($B ($B (($C' $B) (($B _744) (($B _680) ((($C' _680) (($B (_680 "(($A :")) _625)) (($O 32) $K))))))) ((($C' $B) (($B ($C' _744)) ($B _402))) (($B (_744 (_680 ") "))) (($C _744) (_680 (($O 41) $K)))))))))))) $T)) (($B $Y) ((($C' ($C' $S)) ((($C' ($C' $S)) ((($C' $B) $P) ((($S' ($C' $B)) ($B _377)) $I))) ($BK $K))) $K))))) (($B (($S' _743) (($B _740) (($B (_743 _788)) (($B (_680 "main: findIdent: ")) _583))))) (($C' _613) _580)))) _620))) (($B ($B _617)) ((($C' $B) (($B _682) (($B $T) (($B ($C $B)) (($B ($B $BK)) ((($C' ($C' ($C' $O))) ($B (($C' $P) _580))) $K)))))) (($C _698) (_714 0))))))) ($T $A))) ($T $K))) $I)) (($B (_743 _376)) (($B (_743 _577)) (($B (_680 (($O 95) $K))) _625)))))))) (($S (($S ((($S' _8) (($B _697) (_684 (_637 "-v")))) ((_713 _637) "-r"))) (($B (_678 (($O 46) $K))) (($B _742) (_683 ((_702 _764) "-i")))))) (($B (_743 _709)) ((($C' _680) (($B _742) (_683 ((_702 _764) "-o")))) (($O "out.comb") $K))))) (($B (($S (($C ((($C' _775) _697) 1)) (_788 "Usage: mhs [-v] [-r] [-iPATH] [-oFILE] ModuleName"))) _709)) (_684 ((_744 _784) ((_744 (_637 (($O 45) $K))) (_695 1))))))) (_705 ((_744 _784) (_637 "--")))))) (($A :1 "v3.4\10&") (($A :2 ((($S' ($S' _645)) _17) (($B ($B ($B (_645 _674)))) ((($C' ($C' $B)) (($B ($B ($C' (($S' _645) (($B _647) (_736 _222)))))) (($B ($B ($B ($B $T)))) (($B ($B ($B ($B (_645 _674))))) ((($C' $B) (($B ($C' $B)) (($B ($B ($C' _646))) ((($C' $B) ($B' (($B _743) (($B _664) ((($C' _779) _9) 0))))) (($B ($B (_743 _667))) ((($C' ($C' _680)) (($B ($B (_680 "combinator conversion "))) (($B ($B (_639 6))) (($B ($B _625)) _773)))) "ms")))))) (($B ($B _647)) (($B $P) (($C _586) (_577 "main"))))))))) (_682 ($T ((($C' ($C' $O)) ((($C' $B) $P) _405)) $K))))))) (($A :3 (($B (_645 _594)) (($B (($C' _595) ((($C' _768) (($B _697) (_705 ((_744 _784) (_637 "--"))))) 1))) (($B (_743 _7)) _4)))) (($A :4 ($T (($C ((($C' $C') (($B $S) ($C $C))) (($B ($B $Y)) (($B ($B ($B _567))) (($C' ($C' _682)) (($B ($B $T)) ((($C' ($C' ($C' ($C' $O)))) (($B ($B (($C' $B) $P))) ($B _5))) $K))))))) (($B (($S' _743) (($B _740) (($B (_743 _788)) (($B (_680 "not found ")) _583))))) ($C _568))))) (($A :5 ((($C' $C) ((($S' $C) ((($C' ($C' $S')) (($S $P) ((($S' ($C' $B)) (($B ($B _7)) _5)) _5))) ($BK $K))) ((($C' ($S' $C)) ((($C' ($C' $C)) (($B (($C' $C) (($B ($P _7)) $K))) ((($C' $B) _5) _404))) ((($S' _743) (($B _740) (($B (_743 _788)) (_680 "primlookup: ")))) (($C (_719 _637)) _6)))) $K))) (_788 "trans: impossible"))) (($A :6 (($O (($P (($O 66) $K)) $B)) (($O (($P (($O 79) $K)) $O)) (($O (($P (($O 75) $K)) $K)) (($O (($P "C'") $C')) (($O (($P (($O 67)
\ No newline at end of file
--- a/lib/Data/Tuple.hs
+++ b/lib/Data/Tuple.hs
@@ -18,8 +18,5 @@
snd :: forall a b . (a, b) -> b
snd (_, b) = b
-pair :: forall a b . a -> b -> (a, b)
-pair x y = (x, y)
-
eqPair :: forall a b . (a -> a -> Bool) -> (b -> b -> Bool) -> (a, b) -> (a, b) -> Bool
eqPair eqa eqb (a1, b1) (a2, b2) = eqa a1 a2 && eqb b1 b2
--- a/src/MicroHs/Parse.hs
+++ b/src/MicroHs/Parse.hs
@@ -237,7 +237,7 @@
pDef :: P EDef
pDef =
- Data <$> (pKeyword "data" *> pLHS) <*> ((pSymbol "=" *> esepBy1 (pair <$> pUIdentSym <*> emany pAType) (pSymbol "|"))
+ Data <$> (pKeyword "data" *> pLHS) <*> ((pSymbol "=" *> esepBy1 ((,) <$> pUIdentSym <*> emany pAType) (pSymbol "|"))
<|< P.pure [])
<|< Newtype <$> (pKeyword "newtype" *> pLHS) <*> (pSymbol "=" *> pUIdent) <*> pAType
<|< Type <$> (pKeyword "type" *> pLHS) <*> (pSymbol "=" *> pType)
@@ -245,7 +245,7 @@
<|< Sign <$> (pLIdentSym <* pSymbol "::") <*> pTypeScheme
<|< Import <$> (pKeyword "import" *> pImportSpec)
<|< ForImp <$> (pKeyword "foreign" *> pKeyword "import" *> pKeyword "ccall" *> pString) <*> pLIdent <*> (pSymbol "::" *> pType)
- <|< Infix <$> (pair <$> pAssoc <*> pPrec) <*> esepBy1 pTypeOper (pSpec ',')
+ <|< Infix <$> ((,) <$> pAssoc <*> pPrec) <*> esepBy1 pTypeOper (pSpec ',')
where
pAssoc = (AssocLeft <$ pKeyword "infixl") <|< (AssocRight <$ pKeyword "infixr") <|< (AssocNone <$ pKeyword "infix")
dig (TInt _ i) | -1 <= i && i <= 9 = Just i
@@ -253,7 +253,7 @@
pPrec = satisfyM "digit" dig
pLHS :: P LHS
-pLHS = pair <$> pUIdentSym <*> emany pIdKind
+pLHS = (,) <$> pUIdentSym <*> emany pIdKind
pImportSpec :: P ImportSpec
pImportSpec =
@@ -260,7 +260,7 @@
let
pQua = (True <$ pKeyword "qualified") <|< pure False
in ImportSpec <$> pQua <*> pUQIdentA <*> eoptional (pKeyword "as" *> pUQIdent) <*>
- eoptional (pair <$> ((True <$ pKeyword "hiding") <|> pure False) <*> pParens (esepEndBy pImportItem (pSpec ',')))
+ eoptional ((,) <$> ((True <$ pKeyword "hiding") <|> pure False) <*> pParens (esepEndBy pImportItem (pSpec ',')))
pImportItem :: P ImportItem
pImportItem =
@@ -383,7 +383,7 @@
pAltsL :: P () -> P [EAlt]
pAltsL sep =
- esome (pair <$> (pSymbol "|" *> esepBy1 pStmt (pSpec ',')) <*> (sep *> pExpr))
+ esome ((,) <$> (pSymbol "|" *> esepBy1 pStmt (pSpec ',')) <*> (sep *> pExpr))
<|< ((\ e -> [([], e)]) <$> (sep *> pExpr))
pWhere :: P [EBind]
@@ -425,7 +425,7 @@
pCase = ECase <$> (pKeyword "case" *> pExpr) <*> (pKeyword "of" *> pBlock pCaseArm)
pCaseArm :: P ECaseArm
-pCaseArm = pair <$> pPat <*> pAlts (pSymbol "->")
+pCaseArm = (,) <$> pPat <*> pAlts (pSymbol "->")
pLet :: P Expr
pLet = ELet <$> (pKeyword "let" *> pBlock pBind) <*> (pKeyword "in" *> pExpr)
@@ -478,7 +478,7 @@
pExprOp = pOperators pOper pExprArg
pOperators :: P Ident -> P Expr -> P Expr
-pOperators oper one = eOper <$> one <*> emany (pair <$> oper <*> one)
+pOperators oper one = eOper <$> one <*> emany ((,) <$> oper <*> one)
where eOper e [] = e
eOper e ies = EOper e ies
--- a/src/MicroHs/TypeCheck.hs
+++ b/src/MicroHs/TypeCheck.hs
@@ -654,7 +654,7 @@
withExtVal i (ETypeScheme [] k) $ withVars iks ta
tcConstr :: Constr -> T Constr
-tcConstr (i, ts) = pair i <$> T.mapM (\ t -> fst <$> tcTypeT (Just kType) t) ts
+tcConstr (i, ts) = (,) i <$> T.mapM (\ t -> fst <$> tcTypeT (Just kType) t) ts
tcDefsValue :: [EDef] -> T [EDef]
tcDefsValue ds = T.do
@@ -732,7 +732,7 @@
EVar i ->
if isUnderscore i then
-- this only happens with patterns translated into expressions
- pair ae <$> newUVar
+ (,) ae <$> newUVar
else T.do
(e, t) <- tLookupInst "variable" i
-- traceM $ "*** " ++ i ++ " :: " ++ showExpr t ++ " = " ++ showMaybe showExpr mt
@@ -975,7 +975,7 @@
tcPat ::forall a . EType -> EPat -> (EPat -> T a) -> T a
tcPat t ap ta = T.do
-- traceM $ "tcPat: " ++ show ap
- env <- T.mapM (\ v -> (pair v . ETypeScheme []) <$> newUVar) $ filter (not . isUnderscore) $ patVars ap
+ env <- T.mapM (\ v -> ((,) v . ETypeScheme []) <$> newUVar) $ filter (not . isUnderscore) $ patVars ap
withExtVals env $ T.do
(pp, _) <- tcExpr (Just t) ap
() <- checkArity (getSLocExpr ap) 0 pp
--
⑨