cleaner event handler for FixCodeEvent
This commit is contained in:
parent
1e37c2c47b
commit
44588c691a
|
@ -24,7 +24,7 @@ License along with this program. If not, see
|
|||
|
||||
|-}
|
||||
|
||||
{-# LANGUAGE LambdaCase, OverloadedStrings #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Hamming.App.Events (
|
||||
eventHandler,
|
||||
|
@ -47,7 +47,7 @@ import Brick.Keybindings
|
|||
, onEvent
|
||||
)
|
||||
import Control.Monad (void)
|
||||
import Control.Monad.State.Class (get, gets, modify, put)
|
||||
import Control.Monad.State.Class (gets, modify, put)
|
||||
import Data.Either (fromRight)
|
||||
import Graphics.Vty.Input.Events
|
||||
( Event (EvKey)
|
||||
|
@ -95,10 +95,7 @@ keyEventHandlers =
|
|||
, onEvent CheckBitsEvent "Set Check Bits" $
|
||||
hammingCode %= setCheckBits
|
||||
, onEvent FixCodeEvent "Attempt to Correct Errors" $
|
||||
zoom hammingCode $ get >>= \case
|
||||
Nothing -> return ()
|
||||
Just c -> put c
|
||||
. correctErrors
|
||||
zoom hammingCode $ gets correctErrors >>= mapM_ put
|
||||
, onEvent ResetEvent "Reset Code" $
|
||||
hammingCode .= 0
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue
Block a user