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:
MyModule.fromTime : Posix -> MyModule.Structure
which you could call from Main
like:
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)