Skip to content

Commit

Permalink
REPL logic simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Jan 5, 2025
1 parent 4e80631 commit 4d1781d
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/swarm-tui/Swarm/TUI/Controller.hs
Original file line number Diff line number Diff line change
Expand Up @@ -641,14 +641,15 @@ handleREPLEventTyping = \case
modify validateREPLForm
-- Otherwise, just move around in the history as normal.
_ -> modify $ adjReplHistIndex Newer
ControlChar 'r' -> do
s <- get
let uinput = s ^. uiState . uiGameplay . uiREPL . replPromptText
case s ^. uiState . uiGameplay . uiREPL . replPromptType of
CmdPrompt _ -> uiState . uiGameplay . uiREPL . replPromptType .= SearchPrompt (s ^. uiState . uiGameplay . uiREPL . replHistory)
SearchPrompt rh -> case lastEntry uinput rh of
Nothing -> pure ()
Just found -> uiState . uiGameplay . uiREPL . replPromptType .= SearchPrompt (removeEntry found rh)
ControlChar 'r' ->
Brick.zoom (uiState . uiGameplay . uiREPL) $ do
uir <- get
let uinput = uir ^. replPromptText
case uir ^. replPromptType of
CmdPrompt _ -> replPromptType .= SearchPrompt (uir ^. replHistory)
SearchPrompt rh -> case lastEntry uinput rh of
Nothing -> pure ()
Just found -> replPromptType .= SearchPrompt (removeEntry found rh)
CharKey '\t' -> do
s <- get
let names = s ^.. gameState . baseEnv . envTypes . to assocs . traverse . _1
Expand Down Expand Up @@ -796,9 +797,9 @@ validateREPLForm s =
Right (Just theTerm) -> case processParsedTerm' env theTerm of
Right t -> (Just (t ^. sType), Right ())
Left err -> (Nothing, Left (cteSrcLoc err))
in s
& uiState . uiGameplay . uiREPL . replValid .~ errSrcLoc
& uiState . uiGameplay . uiREPL . replType .~ theType
in s . uiState . uiGameplay . uiREPL

Check failure on line 800 in src/swarm-tui/Swarm/TUI/Controller.hs

View workflow job for this annotation

GitHub Actions / Haskell-CI - windows-latest - ghc-9.8.2

• Couldn't match expected type ‘(AppState -> f0 AppState) -> c0’
& replValid .~ errSrcLoc

Check failure on line 801 in src/swarm-tui/Swarm/TUI/Controller.hs

View workflow job for this annotation

GitHub Actions / Haskell-CI - windows-latest - ghc-9.8.2

• Couldn't match type ‘REPLState’
& replType .~ theType

Check failure on line 802 in src/swarm-tui/Swarm/TUI/Controller.hs

View workflow job for this annotation

GitHub Actions / Haskell-CI - windows-latest - ghc-9.8.2

• Couldn't match type ‘REPLState’ with ‘AppState’
SearchPrompt _ -> s
where
uinput = s ^. uiState . uiGameplay . uiREPL . replPromptText
Expand Down

0 comments on commit 4d1781d

Please sign in to comment.