<commit_before>module App.Update where

import Debug
import Effects exposing (Effects)

import App.Action
import App.Model
import App.Router
import Id.Action
import Id.Update
import Retro.Action
import Retro.Update


init : (Int, Int) -> (App.Model, Effects Action)
init randomSeed =
    let
        initialId = Id.Update.init randomSeed
        initialModel = App.Model.initial
        model = { initialModel
            | id = initialId
        }
    in
        ( model
        , Effects.none
        )


update : Action -> App.Model -> (App.Model, Effects Action)
update action model =
    case action of
        App.Action.Route (route, _) ->
            {model | route = route}
                |> Response.withNone
        App.Action.Navigation path ->
            model
                |> Response.withEffects (path |> App.Router.navigateTo |> Effects.map App.Action.Hop)

        -- Service Actions
        App.Action.Service (App.Action.Retro retroAction) ->
            Retro.Update.update retroAction model.retro
                |> Response.mapModel (\retro -> { model | retro = retro })
                |> Response.mapEffects (App.Action.Retro >> App.Action.Service)
        App.Action.Service (App.Action.Id idAction) ->
            Id.Update.update idAction model.id
                |> Response.mapModel (\id -> { model | id = id })
                |> Response.mapEffects (App.Action.Id >> App.Action.Service)

        _ ->
            ( model
            , Effects.none
            )


loggedUpdate : Action -> App.Model -> (App.Model, Effects Action)
loggedUpdate action model =
    let
        action = Debug.log "action" action
        model = Debug.log "model before" model
    in
        Debug.log "model after" (update action model)


router =<commit_msg>Use Response in more places<commit_after>module App.Update where

import Debug
import Effects
import Response exposing (Response)

import App.Action
import App.Model
import App.Router
import Id.Action
import Id.Update
import Retro.Action
import Retro.Update


type alias AppAction = App.Action.Action
type alias AppModel = App.Model.Model
type alias AppResponse = Response AppModel AppAction


init : (Int, Int) -> AppResponse
init randomSeed =
    let
        initialId = Id.Update.init randomSeed
        initialModel = App.Model.initial
        model = { initialModel
            | id = initialId
        }
    in
        model
            |> Response.withNone




update : AppAction -> AppModel -> AppResponse
update action model =
    case action of
        App.Action.Route (route, _) ->
            {model | route = route}
                |> Response.withNone
        App.Action.Navigation path ->
            model
                |> Response.withEffects (path |> App.Router.navigateTo |> Effects.map App.Action.Hop)

        -- Service Actions
        App.Action.Service (App.Action.Retro retroAction) ->
            Retro.Update.update retroAction model.retro
                |> Response.mapModel (\retro -> { model | retro = retro })
                |> Response.mapEffects (App.Action.Retro >> App.Action.Service)
        App.Action.Service (App.Action.Id idAction) ->
            Id.Update.update idAction model.id
                |> Response.mapModel (\id -> { model | id = id })
                |> Response.mapEffects (App.Action.Id >> App.Action.Service)

        _ ->
            model
                |> Response.withNone


loggedUpdate : AppAction -> AppModel -> AppResponse
loggedUpdate action model =
    let
        action = Debug.log "action" action
        model = Debug.log "model before" model
    in
        Debug.log "model after" (update action model)


router =
{'fraction_non_alphanumeric': 0.09740791268758527, 'fraction_numerical': 0.0, 'mean_word_length': 1.982912937347437, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 53, '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': '1830727', 'n_tokens_mistral': 1027, 'n_tokens_neox': 969, 'n_words': 272}