Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion primer/src/Primer/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import qualified Data.Set as Set
import Optics (
Field1 (_1),
Field2 (_2),
Field3 (_3),
ReversibleOptic (re),
over,
toListOf,
Expand Down Expand Up @@ -612,7 +613,9 @@ applyProgAction prog mdefName = \case
type_
updateDefs =
over (traversed % #_DefAST % #astDefExpr) $
transform $ over (#_Con % _2) updateName
transform $
over (#_Con % _2) updateName
. over (#_Case % _3 % traversed % #_CaseBranch % _1) updateName
updateName n = if n == old then new else n
RenameTypeParam type_ old (unsafeMkLocalName -> new) -> do
traverseOf
Expand Down
24 changes: 20 additions & 4 deletions primer/test/Tests/Action/Prog.hs
Original file line number Diff line number Diff line change
Expand Up @@ -794,8 +794,16 @@ unit_RenameCon =
[ do
x <-
hole
( hole
(con cA)
( hole $
case_
( con cA `aPP` tEmptyHole `aPP` tEmptyHole
`app` con (vcn "True")
`app` con (vcn "True")
`app` con (vcn "True")
)
[ branch cA [("p", Nothing), ("q", Nothing), ("p1", Nothing)] emptyHole
, branch cB [("x", Nothing)] emptyHole
]
)
astDef "def" x <$> tEmptyHole
]
Expand All @@ -812,8 +820,16 @@ unit_RenameCon =
@?= forgetIDs
( fst . create $
hole
( hole
(con $ vcn "A'")
( hole $
case_
( con (vcn "A'") `aPP` tEmptyHole `aPP` tEmptyHole
`app` con (vcn "True")
`app` con (vcn "True")
`app` con (vcn "True")
)
[ branch (vcn "A'") [("p", Nothing), ("q", Nothing), ("p1", Nothing)] emptyHole
, branch cB [("x", Nothing)] emptyHole
]
)
)

Expand Down