<commit_before>module Main.Model exposing (..)

import Json.Encode as E
import List.Extra as List
import Main.Msg exposing (..)
import Maybe.Extra as Maybe
import Navigation exposing (Location)
import RandomIdGenerator as Random
import Random.Pcg as Random exposing (Seed)
import Time exposing (Time)
import Todo as Todo exposing (EditMode(..), EncodedTodoList, TodoGroup, Todo, TodoId, TodoList)
import Toolkit.Operators exposing (..)
import Toolkit.Helpers exposing (..)
import Tuple2
import InboxFlow
import TodoStore exposing (TodoStore)
import TodoStore.Model


type ViewState
    = TodoListViewState
    | InboxFlowViewState (Maybe Todo) InboxFlow.Model


type alias Model =
    { now : Time
    , todoList : TodoList
    , editMode : EditMode
    , viewState : ViewState
    , seed : Seed
    }


modelConstructor now todoList editMode ( todoStore, seed ) =
    Model now todoList editMode TodoListViewState seed


type alias ModelMapper =
    Model -> Model


init : Time -> EncodedTodoList -> Model
init now encodedTodoList =
    let
        todoList =
            Todo.decodeTodoList encodedTodoList

        generateTodoModel =
            todoList |> TodoStore.generator >> Random.step

        todoModelFromSeed =
            Random.seedFromTime >> generateTodoModel
    in
        now
            |> todoModelFromSeed
            >> modelConstructor now todoList NotEditing

<commit_msg>Refactoring step 1<commit_after>module Main.Model exposing (..)

import Json.Encode as E
import List.Extra as List
import Main.Msg exposing (..)
import Maybe.Extra as Maybe
import Navigation exposing (Location)
import RandomIdGenerator as Random
import Random.Pcg as Random exposing (Seed)
import Time exposing (Time)
import Todo as Todo exposing (EditMode(..), EncodedTodoList, TodoGroup, Todo, TodoId, TodoList)
import Toolkit.Operators exposing (..)
import Toolkit.Helpers exposing (..)
import Tuple2
import InboxFlow
import TodoStore exposing (TodoStore)
import TodoStore.Model


type ViewState
    = TodoListViewState
    | InboxFlowViewState (Maybe Todo) InboxFlow.Model


type alias Model =
    { now : Time
    , todoList : TodoList
    , editMode : EditMode
    , viewState : ViewState
    , seed : Seed
    }


modelConstructor now todoList editMode seed =
    Model now todoList editMode TodoListViewState seed


type alias ModelMapper =
    Model -> Model


init : Time -> EncodedTodoList -> Model
init now encodedTodoList =
    let
        todoList =
            Todo.decodeTodoList encodedTodoList
    in
        Random.seedFromTime now
            |> modelConstructor now todoList NotEditing


{'fraction_non_alphanumeric': 0.06630893062476044, 'fraction_numerical': 0.0011498658489842851, 'mean_word_length': 3.257748776508972, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '1422747', 'n_tokens_mistral': 782, 'n_tokens_neox': 745, 'n_words': 244}