@@ -524,12 +524,13 @@ infer' (Accessor prop val) = do
524 _ <- subsumes Nothing objTy (Object (RCons prop field rest))
524 _ <- subsumes Nothing objTy (Object (RCons prop field rest))
525 return $ TypedValue True (Accessor prop typed) field
525 return $ TypedValue True (Accessor prop typed) field
526 Just ty -> return $ TypedValue True (Accessor prop typed) ty
526 Just ty -> return $ TypedValue True (Accessor prop typed) ty
527−infer' (Abs arg ret) = do
527+infer' (Abs (Left arg) ret) = do
528 ty <- fresh
528 ty <- fresh
529 Just moduleName <- checkCurrentModule <$> get
529 Just moduleName <- checkCurrentModule <$> get
530 bindLocalVariables moduleName [(arg, ty)] $ do
530 bindLocalVariables moduleName [(arg, ty)] $ do
531 body@(TypedValue _ _ bodyTy) <- infer' ret
531 body@(TypedValue _ _ bodyTy) <- infer' ret
532− return $ TypedValue True (Abs arg body) $ function ty bodyTy
532+ return $ TypedValue True (Abs (Left arg) body) $ function ty bodyTy
533+infer' (Abs (Right _) _) = error "Binder was not desugared"
533infer' (App f arg) = do
534infer' (App f arg) = do
534 f'@(TypedValue _ _ ft) <- infer f
535 f'@(TypedValue _ _ ft) <- infer f
535 (ret, app) <- checkFunctionApplication f' ft arg
536 (ret, app) <- checkFunctionApplication f' ft arg
@@ -728,7 +729,7 @@ check' val t@(ConstrainedType constraints ty) = do
728 TypeClassDictionaryInScope name className instanceTy Nothing TCDRegular) (map (Qualified Nothing) dictNames)
729 TypeClassDictionaryInScope name className instanceTy Nothing TCDRegular) (map (Qualified Nothing) dictNames)
729 (qualifyAllUnqualifiedNames moduleName env constraints)) $
730 (qualifyAllUnqualifiedNames moduleName env constraints)) $
730 check val ty
731 check val ty
731− return $ TypedValue True (foldr Abs val' dictNames) t
732+ return $ TypedValue True (foldr Abs val' (map Left dictNames)) t
732check' val t@(SaturatedTypeSynonym name args) = do
733check' val t@(SaturatedTypeSynonym name args) = do
733 ty <- introduceSkolemScope <=< expandTypeSynonym name $ args
734 ty <- introduceSkolemScope <=< expandTypeSynonym name $ args
734 val' <- check val ty
735 val' <- check val ty
@@ -748,10 +749,11 @@ check' v@(BooleanLiteral _) t | t == tyBoolean =
748check' (ArrayLiteral vals) t@(TypeApp a ty) | a == tyArray = do
749check' (ArrayLiteral vals) t@(TypeApp a ty) | a == tyArray = do
749 arr <- ArrayLiteral <$> forM vals (\val -> check val ty)
750 arr <- ArrayLiteral <$> forM vals (\val -> check val ty)
750 return $ TypedValue True arr t
751 return $ TypedValue True arr t
751−check' (Abs arg ret) ty@(TypeApp (TypeApp t argTy) retTy) | t == tyFunction = do
752+check' (Abs (Left arg) ret) ty@(TypeApp (TypeApp t argTy) retTy) | t == tyFunction = do
752 Just moduleName <- checkCurrentModule <$> get
753 Just moduleName <- checkCurrentModule <$> get
753 ret' <- bindLocalVariables moduleName [(arg, argTy)] $ check ret retTy
754 ret' <- bindLocalVariables moduleName [(arg, argTy)] $ check ret retTy
754− return $ TypedValue True (Abs arg ret') ty
755+ return $ TypedValue True (Abs (Left arg) ret') ty
756+check' (Abs (Right _) _) _ = error "Binder was not desugared"
755check' (App f arg) ret = do
757check' (App f arg) ret = do
756 f'@(TypedValue _ _ ft) <- infer f
758 f'@(TypedValue _ _ ft) <- infer f
757 (ret', app) <- checkFunctionApplication f' ft arg
759 (ret', app) <- checkFunctionApplication f' ft arg