mirror of
https://github.com/rgleichman/glance.git
synced 2024-09-11 15:05:41 +03:00
Integrated text for tuples and sections.
This commit is contained in:
parent
692577138d
commit
3852a8a492
@ -358,14 +358,14 @@ caseIcon ::(RealFloat n,
|
||||
caseIcon = generalGuardIcon (patternC colorScheme) caseC caseResult
|
||||
|
||||
-- | The ports of flatLambdaIcon are:
|
||||
-- 0: Optional result icon
|
||||
-- 0: Result icon
|
||||
-- 1: The lambda function value
|
||||
-- 2,3.. : The parameters
|
||||
flatLambda n = finalDia where
|
||||
lambdaCircle = circle circleRadius # fc (regionPerimC colorScheme) # lc (regionPerimC colorScheme) # lwG defaultLineWidth
|
||||
lambdaParts = (makePort 0 <> resultIcon) : (portIcons ++ [makePort 1 <> (alignR lambdaCircle)])
|
||||
lambdaParts = (makePort 0 <> resultIcon) : (portIcons ++ [makePort 1 <> alignR lambdaCircle])
|
||||
portIcons = take n $ map (\x -> makePort x <> portCircle) [2,3..]
|
||||
middle = alignL (hsep 0.5 lambdaParts)
|
||||
topAndBottomLineWidth = width middle - circleRadius
|
||||
topAndBottomLine = hrule topAndBottomLineWidth # lc (regionPerimC colorScheme) # lwG defaultLineWidth # alignL
|
||||
finalDia = topAndBottomLine <> (alignB $ topAndBottomLine <> (middle # alignT))
|
||||
finalDia = topAndBottomLine <> alignB (topAndBottomLine <> (middle # alignT))
|
||||
|
@ -104,6 +104,10 @@ evalQOp :: QOp -> EvalContext -> State IDState (IconGraph, Reference)
|
||||
evalQOp (QVarOp n) = evalQName n
|
||||
evalQOp (QConOp n) = evalQName n
|
||||
|
||||
qOpToString :: QOp -> String
|
||||
qOpToString (QVarOp n) = qNameToString n
|
||||
qOpToString (QConOp n) = qNameToString n
|
||||
|
||||
makeTextApplyGraph :: Bool -> DIA.Name -> String -> [(IconGraph, Reference)] -> Int -> (IconGraph, NameAndPort)
|
||||
makeTextApplyGraph inPattern applyIconName funStr argVals numArgs = (newGraph <> combinedGraph, nameAndPort applyIconName 1)
|
||||
where
|
||||
@ -301,9 +305,8 @@ evalCase c e alts = do
|
||||
evalTuple :: EvalContext -> [Exp] -> State IDState (IconGraph, NameAndPort)
|
||||
evalTuple c exps = do
|
||||
argVals <- mapM (evalExp c) exps
|
||||
funVal <- makeBox $ nTupleString (length exps)
|
||||
applyIconName <- DIA.toName <$> getUniqueName "tupleApp"
|
||||
pure $ makeApplyGraph False applyIconName (fmap Right funVal) argVals (length exps)
|
||||
pure $ makeTextApplyGraph False applyIconName (nTupleString (length exps)) argVals (length exps)
|
||||
|
||||
makeVarExp = Var . UnQual . Ident
|
||||
|
||||
@ -317,11 +320,10 @@ evalLeftSection c e op = evalApp c (qOpToExp op, [e])
|
||||
evalRightSection:: EvalContext -> QOp -> Exp -> State IDState (IconGraph, NameAndPort)
|
||||
evalRightSection c op e = do
|
||||
expVal <- evalExp c e
|
||||
funVal <- evalQOp op c
|
||||
applyIconName <- DIA.toName <$> getUniqueName "tupleApp"
|
||||
-- TODO: A better option would be for makeApplyGraph to take the list of expressions as Maybes.
|
||||
neverUsedPort <- Left <$> getUniqueName "unusedArgument"
|
||||
pure $ makeApplyGraph False applyIconName funVal [(mempty, neverUsedPort), expVal] 2
|
||||
pure $ makeTextApplyGraph False applyIconName (qOpToString op) [(mempty, neverUsedPort), expVal] 2
|
||||
|
||||
-- evalEnums is only used by evalExp
|
||||
evalEnums :: EvalContext -> String -> [Exp] -> State IDState (IconGraph, Reference)
|
||||
|
Loading…
Reference in New Issue
Block a user