<commit_before>{-#LANGUAGE OverloadedStrings, TemplateHaskell #-}

import Hom.Animate
import Hom.MainLoop
import Hom.DOM
import Hom.VDOM
import Control.Monad
import Control.Lens
import Data.Text (pack)

import Control.Concurrent
import Control.Monad.Trans.State
import Control.Monad.IO.Class

data AppState = AppState { _counter :: Int }

initialState = AppState 0 
makeLenses ''AppState

counterComp :: Int -> Node
counterComp i = node "div" emptyProps [ text . pack . show $ i]
render state = 
  node "div" emptyProps
    [ text "test"
    , counterComp $ state^.counter]


app ::  LoopHandle AppState -> StateT AppState IO ()
app handle = forever $ do
  liftIO . threadDelay $ 1000 * 1000
  counter += 1
  state <- get
  liftIO $ update handle state
main = do
  body <- getBody

  handle <- mainLoop initialState render
  body `appendChild`  target handle

  runStateT (app handle) initialState
  
<commit_msg>this is cleaner<commit_after>{-#LANGUAGE OverloadedStrings, TemplateHaskell #-}

import Hom.Animate
import Hom.MainLoop
import Hom.DOM
import Hom.VDOM
import Control.Monad
import Control.Lens
import Data.Text (pack)

import Control.Concurrent
import Control.Monad.Trans.State
import Control.Monad.IO.Class

data AppState = AppState { _counter :: Int }

initialState = AppState 0 
makeLenses ''AppState

counterComp :: Int -> Node
counterComp i = node "div" emptyProps [ text . pack . show $ i]
render state = 
  node "div" emptyProps
    [ text "test"
    , counterComp $ state^.counter]


app ::  LoopHandle AppState -> StateT AppState IO ()
app handle = forever $ do
  liftIO . threadDelay $ 1000 * 1000
  counter += 1
  state <- get
  liftIO $ update handle state
main = do
  body <- getBody

  handle <- mainLoop initialState render
  body `appendChild`  target handle

  evalStateT (app handle) initialState
  

{'fraction_non_alphanumeric': 0.0896664844177146, 'fraction_numerical': 0.010934937124111536, 'mean_word_length': 3.7532467532467533, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7451121', 'n_tokens_mistral': 594, 'n_tokens_neox': 552, 'n_words': 188}