mirror of
https://github.com/rgleichman/glance.git
synced 2024-08-16 18:30:36 +03:00
Remove non-nested apply and compose icons.
This commit is contained in:
parent
bc5ac3fa80
commit
33eac07c59
@ -67,10 +67,6 @@ lineCol = lineC colorScheme
|
||||
|
||||
iconToDiagram :: SpecialBackend b n => Icon -> TransformableDia b n
|
||||
iconToDiagram icon = case icon of
|
||||
ApplyAIcon n ->
|
||||
nestedApplyDia ApplyNodeFlavor Nothing $ replicate (1 + n) Nothing
|
||||
ComposeIcon n ->
|
||||
nestedApplyDia ComposeNodeFlavor Nothing $ replicate (1 + n) Nothing
|
||||
PAppIcon n str ->
|
||||
generalTextAppDia (patternTextC colorScheme) (patternC colorScheme) n str
|
||||
TextBoxIcon s -> textBox s
|
||||
@ -165,8 +161,6 @@ nestedGuardPortAngles args port maybeNodeName = case maybeNodeName of
|
||||
|
||||
getPortAngles :: SpecialNum n => Icon -> Port -> Maybe NodeName -> [Angle n]
|
||||
getPortAngles icon port maybeNodeName = case icon of
|
||||
ApplyAIcon _ -> applyPortAngles port
|
||||
ComposeIcon _ -> applyPortAngles port
|
||||
PAppIcon _ _ -> applyPortAngles port
|
||||
TextBoxIcon _ -> []
|
||||
BindTextBoxIcon _ -> []
|
||||
|
@ -246,12 +246,13 @@ nListString 1 = "[_]"
|
||||
nListString n = '[' : replicate (n -1) ',' ++ "]"
|
||||
|
||||
nodeToIcon :: SyntaxNode -> Icon
|
||||
nodeToIcon (LikeApplyNode ApplyNodeFlavor n) = ApplyAIcon n
|
||||
nodeToIcon (LikeApplyNode ComposeNodeFlavor n) = ComposeIcon n
|
||||
nodeToIcon (NestedApplyNode flavor x edges) = nestedApplySyntaxNodeToIcon flavor x edges
|
||||
nodeToIcon (LikeApplyNode flavor n)
|
||||
= NestedApply flavor Nothing (replicate n Nothing)
|
||||
nodeToIcon (NestedApplyNode flavor x edges)
|
||||
= nestedApplySyntaxNodeToIcon flavor x edges
|
||||
nodeToIcon (PatternApplyNode s n) = PAppIcon n s
|
||||
-- nodeToIcon (NestedPatternApplyNode s n children) = nestedPatternNodeToIcon s n children
|
||||
nodeToIcon (NestedPatternApplyNode s children) = nestedPatternNodeToIcon s children
|
||||
nodeToIcon (NestedPatternApplyNode s children)
|
||||
= nestedPatternNodeToIcon s children
|
||||
nodeToIcon (NameNode s) = TextBoxIcon s
|
||||
nodeToIcon (BindNameNode s) = BindTextBoxIcon s
|
||||
nodeToIcon (LiteralNode s) = TextBoxIcon s
|
||||
@ -259,7 +260,8 @@ nodeToIcon (FunctionDefNode x) = FlatLambdaIcon x
|
||||
nodeToIcon (GuardNode n) = GuardIcon n
|
||||
nodeToIcon (CaseNode n) = CaseIcon n
|
||||
nodeToIcon CaseResultNode = CaseResultIcon
|
||||
nodeToIcon (NestedCaseOrGuardNode tag x edges) = nestedCaseOrGuardNodeToIcon tag x edges
|
||||
nodeToIcon (NestedCaseOrGuardNode tag x edges)
|
||||
= nestedCaseOrGuardNodeToIcon tag x edges
|
||||
|
||||
makeArg :: [(SgNamedNode, Edge)] -> Port -> Maybe NamedIcon
|
||||
makeArg args port = case find (findArg port) args of
|
||||
|
@ -36,8 +36,10 @@ data NamedIcon = NamedIcon {niName :: NodeName, niIcon :: Icon}
|
||||
data Icon = TextBoxIcon String
|
||||
| GuardIcon
|
||||
Int -- Number of alternatives
|
||||
| FlatLambdaIcon [String] | ApplyAIcon Int | ComposeIcon Int
|
||||
| PAppIcon Int String | CaseIcon Int | CaseResultIcon
|
||||
| FlatLambdaIcon [String]
|
||||
| PAppIcon Int String
|
||||
| CaseIcon Int
|
||||
| CaseResultIcon
|
||||
| BindTextBoxIcon String
|
||||
| NestedApply
|
||||
LikeApplyFlavor -- apply or compose
|
||||
@ -55,6 +57,7 @@ data CaseOrGuardTag = CaseTag | GuardTag deriving (Show, Eq, Ord)
|
||||
-- TODO remove Ints from SyntaxNode data constructors.
|
||||
data SyntaxNode =
|
||||
LikeApplyNode LikeApplyFlavor Int -- Function application, composition, and applying to a composition
|
||||
-- NestedApplyNode is only created in GraphAlgorithms, not during translation.
|
||||
| NestedApplyNode LikeApplyFlavor Int [(SgNamedNode, Edge)]
|
||||
| PatternApplyNode String Int -- Destructors as used in patterns
|
||||
-- | NestedPatternApplyNode String Int [(SgNamedNode, Edge)]
|
||||
|
@ -18,63 +18,6 @@ iconToIntPort x y p = iconToPort x y (Port p)
|
||||
intPortToPort :: NodeName -> Int -> NodeName -> Int -> Edge
|
||||
intPortToPort x1 port1 x2 port2 = portToPort x1 (Port port1) x2 (Port port2)
|
||||
|
||||
drawing0 :: Drawing
|
||||
drawing0 = Drawing d0Icons d0Edges where
|
||||
[d0A, d0B, d0Res, d0Foo, d0Bar] = fmap NodeName [0..4] --["A", "B", "res", "foo", "bar"]
|
||||
d0Icons = fmap tupleToNamedIcon
|
||||
[(d0A, ApplyAIcon 1),
|
||||
(d0B, ApplyAIcon 1),
|
||||
(d0Res, CaseResultIcon),
|
||||
(d0Foo, TextBoxIcon "foo"),
|
||||
(d0Bar, TextBoxIcon "bar")
|
||||
]
|
||||
d0Edges =
|
||||
[
|
||||
intPortToPort d0A 0 d0B 1,
|
||||
iconToIntPort d0Foo d0B 0,
|
||||
iconToIntPort d0Res d0A 1,
|
||||
iconToIntPort d0Foo d0B 0,
|
||||
iconToIntPort d0Bar d0B 2,
|
||||
iconToIntPort d0Bar d0A 2
|
||||
]
|
||||
|
||||
|
||||
fG0, fOne, fEq0, fMinus1, fEq0Ap, fMinus1Ap, fTimes, fRecurAp, fTimesAp, fArg, fRes :: NodeName
|
||||
[fG0, fOne, fEq0, fMinus1, fEq0Ap, fMinus1Ap, fTimes, fRecurAp, fTimesAp, fArg, fRes] =
|
||||
fmap NodeName [0..10]
|
||||
-- ["g0", "one", "eq0", "-1", "eq0Ap", "-1Ap", "*", "recurAp", "*Ap", "arg", "res"]
|
||||
|
||||
fact0Drawing :: Drawing
|
||||
fact0Drawing = Drawing fact0Icons fact0Edges where
|
||||
fact0Icons = fmap tupleToNamedIcon
|
||||
[
|
||||
(fG0, GuardIcon 2),
|
||||
(fOne, TextBoxIcon "1"),
|
||||
(fEq0, TextBoxIcon "== 0"),
|
||||
(fMinus1, TextBoxIcon "-1"),
|
||||
(fEq0Ap, ApplyAIcon 1),
|
||||
(fMinus1Ap, ApplyAIcon 1),
|
||||
(fTimes, TextBoxIcon "*"),
|
||||
(fRecurAp, ApplyAIcon 1),
|
||||
(fTimesAp, ApplyAIcon 2),
|
||||
-- (fArg, BranchIcon),
|
||||
(fRes, CaseResultIcon)
|
||||
]
|
||||
fact0Edges = [
|
||||
iconToIntPort fEq0 fEq0Ap 0,
|
||||
intPortToPort fEq0Ap 1 fG0 3,
|
||||
iconToIntPort fMinus1 fMinus1Ap 0,
|
||||
iconToIntPort fTimes fTimesAp 0,
|
||||
iconToIntPort fOne fG0 2,
|
||||
intPortToPort fTimesAp 2 fG0 4,
|
||||
intPortToPort fRecurAp 1 fTimesAp 3,
|
||||
iconToIntPort fArg fEq0Ap 2,
|
||||
iconToIntPort fArg fMinus1Ap 2,
|
||||
iconToIntPort fArg fTimesAp 1,
|
||||
intPortToPort fMinus1Ap 1 fRecurAp 2,
|
||||
iconToIntPort fRes fG0 0
|
||||
]
|
||||
|
||||
-- TODO refactor these Drawings
|
||||
nestedCaseDrawing :: Drawing
|
||||
nestedCaseDrawing = Drawing icons [] where
|
||||
@ -166,8 +109,6 @@ renderTests = do
|
||||
pure vCattedDrawings
|
||||
where
|
||||
allDrawings = [
|
||||
drawing0,
|
||||
fact0Drawing,
|
||||
nestedCaseDrawing,
|
||||
nestedGuardDrawing,
|
||||
flatCaseDrawing,
|
||||
|
Loading…
Reference in New Issue
Block a user