That's a pretty chunky main function compared to what I've seen before.
I completely agree. It would be a lot better to change from GotInitialViewport Viewport to GotInitialViewport (Result x Viewport) (I'm not entirely sure what the type of the error is there). This moves the error handling to your update instead of your init.
I'm still catching up as I'm about 5 days behind, but from today's post it seems like you've been struggling with type variables a lot. Taking a look at guide.elm-lang.org/types/reading_t... another time might help. I don't have any specific resources for learning more about types but I'll try to find some.
When you say
I completely agree. It would be a lot better to change from
GotInitialViewport Viewport
toGotInitialViewport (Result x Viewport)
(I'm not entirely sure what the type of the error is there). This moves the error handling to yourupdate
instead of yourinit
.I'm still catching up as I'm about 5 days behind, but from today's post it seems like you've been struggling with type variables a lot. Taking a look at guide.elm-lang.org/types/reading_t... another time might help. I don't have any specific resources for learning more about types but I'll try to find some.
Thanks for the link! Yeah, that's an area I've been confused by, particularly when reading documentation.
I was kind of frustrated by the
Task x Viewport
, but reading the documentation again now, I see that it refers to an unsuccessfulTask
execution:package.elm-lang.org/packages/elm/...
As I suspected, coming back to this project after having slept well, things make a lot more sense to me now.