Skip to content

Commit

Permalink
feat!: render wildcards as NoBody
Browse files Browse the repository at this point in the history
Previously we emitted it as a TextBody with contents "_". This is a
rendering decision that should be left to a frontend.
  • Loading branch information
brprice committed May 30, 2023
1 parent 06e540f commit ba4cc75
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 30 deletions.
11 changes: 1 addition & 10 deletions primer/src/Primer/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -835,20 +835,11 @@ viewTreeExpr e0 = case e0 of
-- since node IDs in the input expression are unique,
-- and don't contain non-numerical characters
boxId = nodeId <> "Pwild"
patternRootId = boxId <> "B"
in
Just $
Tree
{ nodeId = boxId
, body =
BoxBody . RecordPair Flavor.Pattern $
( Tree
{ nodeId = patternRootId
, body = TextBody $ RecordPair Flavor.PatternWildcard (Name Nothing "_")
, childTrees = []
, rightChild = Nothing
}
)
, body = NoBody Flavor.PatternWildcard
, childTrees = [viewTreeExpr rhs]
, rightChild = Nothing
}
Expand Down
2 changes: 1 addition & 1 deletion primer/src/Primer/API/NodeFlavor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ data NodeFlavorTextBody
| Letrec
| PatternBind
| PatternCon
| PatternWildcard
| TCon
| TVar
| TForall
Expand Down Expand Up @@ -64,6 +63,7 @@ data NodeFlavorNoBody
| THole
| TFun
| TApp
| PatternWildcard
deriving stock (Show, Read, Eq, Generic, Enum, Bounded)
deriving (ToJSON, FromJSON) via PrimerJSON NodeFlavorNoBody
deriving anyclass (NFData)
20 changes: 1 addition & 19 deletions primer/test/outputs/APITree/Expr
Original file line number Diff line number Diff line change
Expand Up @@ -489,25 +489,7 @@ Tree
, rightChild = Just
( Tree
{ nodeId = "39Pwild"
, body = BoxBody
( RecordPair
{ fst = Pattern
, snd = Tree
{ nodeId = "39PwildB"
, body = TextBody
( RecordPair
{ fst = PatternWildcard
, snd = Name
{ qualifiedModule = Nothing
, baseName = "_"
}
}
)
, childTrees = []
, rightChild = Nothing
}
}
)
, body = NoBody PatternWildcard
, childTrees =
[ Tree
{ nodeId = "46"
Expand Down

0 comments on commit ba4cc75

Please sign in to comment.