DEV Community

Discussion on: #30daysofelm Day 20: Getting the browser's width and height

Collapse
 
wolfadex profile image
Wolfgang Schuster

When you say

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.

Collapse
 
kristianpedersen profile image
Kristian Pedersen

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 unsuccessful Task execution:

In each case we have a Task that will resolve successfully with an a value or unsuccessfully with an x value.

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.