mirror of
https://github.com/rgleichman/glance.git
synced 2024-09-11 15:05:41 +03:00
Fix some instances of <$> not being converted to fmap.
This commit is contained in:
parent
dd43ebd994
commit
0185257444
@ -205,7 +205,6 @@ evalInfixApp :: EvalContext -> Exp -> QOp -> Exp -> State IDState (SyntaxGraph,
|
||||
evalInfixApp c e1 op e2 = case op of
|
||||
QVarOp (UnQual (Symbol sym)) -> case sym of
|
||||
"$" -> evalExp c (App e1 e2)
|
||||
"<$>" -> evalExp c $ App (App (makeVarExp "fmap") e1) e2
|
||||
"." -> fmap Right <$> evalCompose c (e1 : simplifyCompose e2)
|
||||
_ -> defaultCase
|
||||
_ -> defaultCase
|
||||
@ -237,6 +236,7 @@ simplifyExp e = case removeParen e of
|
||||
InfixApp exp1 (QVarOp (UnQual (Symbol "$"))) exp2 -> App exp1 exp2
|
||||
-- Don't convert compose to apply
|
||||
InfixApp _ (QVarOp (UnQual (Symbol "."))) _ -> e
|
||||
App (Var (UnQual (Symbol "<$>"))) arg -> App (makeVarExp "fmap") arg
|
||||
InfixApp exp1 op exp2 -> App (App (qOpToExp op) exp1) exp2
|
||||
LeftSection exp1 op -> App (qOpToExp op) exp1
|
||||
x -> x
|
||||
|
@ -354,14 +354,24 @@ lambdaTests = TestList [
|
||||
]
|
||||
]
|
||||
|
||||
-- Yes, the commas get their own line
|
||||
translateUnitTests :: Test
|
||||
translateUnitTests = TestList [
|
||||
TestLabel "fmapTest" $ assertEqualSyntaxGraphs [
|
||||
fmapTests :: Test
|
||||
fmapTests = TestList [
|
||||
assertEqualSyntaxGraphs [
|
||||
"y = fmap f x",
|
||||
"y = f <$> x"
|
||||
]
|
||||
,
|
||||
assertEqualSyntaxGraphs [
|
||||
"y = f1 (fmap f2 (f3 x))",
|
||||
"y = f1 $ f2 <$> f3 x"
|
||||
]
|
||||
]
|
||||
|
||||
-- Yes, the commas get their own line
|
||||
translateUnitTests :: Test
|
||||
translateUnitTests = TestList [
|
||||
TestLabel "fmapTest" fmapTests
|
||||
,
|
||||
TestLabel "applyTests" applyTests
|
||||
,
|
||||
TestLabel "composeApplyTests" composeApplyTests
|
||||
|
5
todo.txt
5
todo.txt
@ -1,4 +1,5 @@
|
||||
-- TODO Now --
|
||||
Case icon that can embed literals
|
||||
|
||||
Consider adding binding variable names to the lambda icon and match icon. Don't display the name if it is only one character.
|
||||
|
||||
@ -10,11 +11,11 @@ Fix the arrowheads being too big for SyntaxGraph drawings.
|
||||
|
||||
-- Visual todos:
|
||||
Draw bounding boxes for lambdas (use dashed lines)
|
||||
Case icon that can embed literals
|
||||
|
||||
-- Make an icon font/library with labeled ports. E.g. the apply icon would have text labels "function", "result", "arg 0", "arg 1", etc.
|
||||
-- Don't rotate text and nested icons, give them rectangular bounding boxes in GraphViz. (Perhaps use a typeclass for isRotateAble)
|
||||
-- Give lines a black border to make line crossings easier to see.
|
||||
-- Let lines connect to ports in multiple locations (e.g. case value, or guard result)
|
||||
-- Let lines connect to ports in multiple locations (e.g. guard result)
|
||||
-- Use different line styles (e.g. dashed, solid, wavy) in addition to colors
|
||||
Use diagrams to shrink the drawing until icons start overlapping.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user