From 99bd927d923904e29405fdfe34c3487ad777ebf6 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Mon, 3 Mar 2025 16:39:45 +0100 Subject: format `app/Main.hs` --- app/Main.hs | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index 53c2521..a58613e 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -93,24 +93,28 @@ component = H.ComponentSpec { initialState, render, - eval = H.mkEval $ H.defaultEval {handleAction, handleQuery, initialize = Nothing} + eval = + H.mkEval $ + H.defaultEval + { handleAction, + handleQuery, + initialize = Nothing + } } where initialState _ = pure testChats - render :: (MonadDOM m, MonadUnliftIO m) => [Chat] -> H.ComponentHTML Action slots m + render :: + (MonadDOM m, MonadUnliftIO m) => + [Chat] -> + H.ComponentHTML Action slots m render chats = HH.div_ $ fmap ( \(index, (Chat chatMessages draft)) -> HH.div_ [ HH.div_ - ( fmap - ( \(Message message) -> - HH.text message - ) - chatMessages - ), + (fmap (\(Message message) -> HH.text message) chatMessages), HH.input [ HP.value draft, HE.onInputValueChange $ Just . (DraftChanged index), @@ -131,10 +135,7 @@ component = modify $ \chats -> fmap ( \(indexOther, chat) -> - if indexOther == index - then - chat {draft = draft} - else chat + if indexOther == index then chat {draft = draft} else chat ) (zip [1 ..] chats) get >>= H.raise @@ -144,11 +145,7 @@ component = ( \(indexOther, chat) -> if indexOther == index then - chat - { chatMessages = - chat.chatMessages - ++ [Message chat.draft] - } + chat {chatMessages = chat.chatMessages ++ [Message chat.draft]} else chat ) (zip [1 ..] chats) -- cgit v1.2.3