Hi,
Welcome to Elm Discourse.
How about something like this?
type alias Scene data =
{ entities : List Int
, components : List (Component data)
, systems : List (Scene -> Scene)
}
type alias Component data =
{ id : Int
, parent : Int
, data : data
}
type ComponentData
= Name String
| Player
| Health { current : Float, max : Float }
When you define your Scene type on your Model you’d do the following:
type alias Model =
{ scene : Scene ComponentData
, ...
}
Now you can apply functions to your list of components because the compiler knows what type the type variable data is.
Just a thought…
p.s. Did you make a typo in your Scene type because it’s recursive and so won’t compile.