Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile sections #21

Merged
merged 4 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions HsUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ pApp c@(UnQual () (Symbol () _)) [p, q] = PInfixApp () p c q
pApp c@(Special () Cons{}) [p, q] = PInfixApp () p c q
pApp c ps = PApp () c ps

getOp :: Exp () -> Maybe (QOp ())
getOp (Var _ x) | isOp x = Just $ QVarOp () x
getOp (Con _ c) | isOp c = Just $ QConOp () c
getOp _ = Nothing

eApp :: Exp () -> [Exp ()] -> Exp ()
eApp f (a : b : as) | Just op <- getOp f = foldl (App ()) (InfixApp () a op b) as
where getOp (Var _ x) | isOp x = Just $ QVarOp () x
getOp (Con _ c) | isOp c = Just $ QConOp () c
getOp _ = Nothing
eApp f [a] | Just op <- getOp f = LeftSection () a op
eApp f es = foldl (App ()) f es

tApp :: Type () -> [Type ()] -> Type ()
Expand All @@ -72,7 +75,7 @@ hsLambda x e =
p = PVar () $ hsName x

getExplicitImports :: ImportSpec l -> [String]
getExplicitImports = map pp . \case
getExplicitImports = map pp . \case
IVar _ n -> [n]
IAbs _ _ n -> [n]
IThingAll _ n -> [n]
Expand Down
2 changes: 1 addition & 1 deletion test/golden/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ map f [] = []
map f (x : xs) = f x : map f xs

mapTest :: [Integer] -> [Integer]
mapTest = map (id . (+) 5)
mapTest = map (id . (5 +))
omelkonian marked this conversation as resolved.
Show resolved Hide resolved

plus3 :: [Integer] -> [Integer]
plus3 = map (\ n -> n + 3)
Expand Down