From a81c92dc2cdff02c55fdc197d943bc7a35c64be5 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Tue, 7 May 2024 14:21:13 -0400 Subject: fig-emulator-gb: Fix space leak --- fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs') diff --git a/fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs b/fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs index 59200f1..0ee529b 100644 --- a/fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs +++ b/fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs @@ -18,16 +18,18 @@ instance Pretty SerialError where , b ] -compSerial :: (MonadIO m, MonadThrow m) => Handle -> Component m -compSerial h = Component +compSerial :: (MonadIO m, MonadThrow m) => Maybe Handle -> Component m +compSerial mh = Component { compState = () , compMatches = (== 0xff01) , compUpdate = \s _ -> pure s , compWrite = \s _ v -> do - log $ mconcat - [ "wrote serial byte: ", tshow $ chr $ fromIntegral v - ] - liftIO . hPutChar h . chr $ fromIntegral v + -- log $ mconcat + -- [ "wrote serial byte: ", tshow $ chr $ fromIntegral v + -- ] + case mh of + Nothing -> pure () + Just h -> liftIO . hPutChar h . chr $ fromIntegral v pure s , compRead = \_ _ -> pure 0x00 } -- cgit v1.2.3