rgrempel / elm-route-url

Router for single-page-apps in Elm
http://package.elm-lang.org/packages/rgrempel/elm-route-url/latest
MIT License
196 stars 16 forks source link

Update for Elm 0.18 (based on @pzingg's #19) #22

Closed rgrempel closed 7 years ago

rgrempel commented 7 years ago

In working through @pzingg's comprehensive PR #19 for updating elm-route-url to Elm 0.18, it seemed as though it would be easiest for me to take it as a starting point, and then add my own edits. So, that is what this PR tracks ... it's a work-in-progress as I go through @pzingg's admirable work.

pzingg commented 7 years ago

I am learning about Elm and its community. I was looking at the spot in your code where you pump the messages returned from location2messages through the user's update function using a List.foldl operation. Someone pointed me to the Update.Extra library from ccapndave. My latest commit, 119f54a gets rid of the processLocationMessages function and just uses Update.Extra.sequence, which does the same thing and is perhaps more elegant and generic. This also cleaned up the type annotations on the initImpl, updateImpl and urlUpdateImpl functions, but of course it introduces a dependency on the Update.Extra library.

rgrempel commented 7 years ago

So, one of the changes in Elm 0.18 is that the Program type is now parameterized by the Model and Msg types ... i.e. it is Program flags model msg now rather than Program flags.

So, as @pzingg noted, in order to allow programs to type their main function, we now need to export the model type and msg type which we use as "wrappers" (containing the user's model and msg types, along with the ones which we use).

What I'm working on now is exporting those types in a way that doesn't expose very much of the internals. It's (potentially) useful to let the clients of the library manipulate the wrapped models with their own types, but one wants to avoid exposing arbitrary details of the implementation.