# Init a task in a module + avoid circular import?

**URL:** <https://discourse.elm-lang.org/t/init-a-task-in-a-module-avoid-circular-import/6287>\
**Category:** Learn\
**Created:** [September 18, 2020, 12:02am UTC](https://discourse.elm-lang.org/t/init-a-task-in-a-module-avoid-circular-import/6287 "2020-09-18T00:02:39Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![joelq](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/joelq/32/445_2.png) [@joelq](https://discourse.elm-lang.org/u/joelq)\
**Post date:** [September 18, 2020, 2:45pm UTC](https://discourse.elm-lang.org/t/init-a-task-in-a-module-avoid-circular-import/6287/3 "2020-09-18T14:45:59Z")

</div>

Reading between the lines, it sounds like you are trying to build your project using a “fractal architecture” with a bunch of modules that each define `init`/`update`/`view`, etc. Most extracted modules in Elm apps are not structured this way. Instead, they are usually just a data structure and some functions that act upon it (think the Elm core library). The `init`/`update`/`view` functions are not magic framework functions and modules don’t need to implement them.

It’s hard to make an definite recommendations without more context on what you are doing but most solutions likely involve passing in the time as an argument as suggested by @pdamoc.

For example you might create some sort of constructor for your custom data structure in the module like:

```elm
MyModule.fromTime : Posix -> MyModule.Structure

```

which you could call from `Main` like:

```elm
module Main exposing(main)

import MyModule

init : Flags -> (Model, Cmd Msg)
init flags =
  (initialModel, Task.perform GotInitialTime Time.now)

update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
  case msg of
    GotInitialTime time ->
      ({ model | structure = MyModule.fromTime time }, Cmd.none)

```

---

_[View the full topic](https://discourse.elm-lang.org/t/init-a-task-in-a-module-avoid-circular-import/6287)._
