Advertisement
Guest User

Untitled

a guest
Apr 12th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. From the location below, I'd like to get the `page` param:
  2.  
  3. ```
  4. > location
  5. { href = "", host = "", hostname = "", protocol = "", origin = "", port_ = "", pathname = "/admin/sites/91c2a015-6f2c-47fc-bc76-c136e2401058/residents", search = "?page=2", hash = "", username = "", password = "" }
  6. : Navigation.Location
  7. ```
  8.  
  9. Currently I can parse it using this location (without the UUID):
  10.  
  11. ```
  12. > another_location
  13. { href = "", host = "", hostname = "", protocol = "", origin = "", port_ = "", pathname = "/admin/sites/residents", search = "?page=2", hash = "", username = "", password = "" }
  14. : Navigation.Location
  15.  
  16. > parsePath (s "admin" </> s "sites" </> s "residents" <?> intParam "page") another_location
  17. Just (Just 2) : Maybe.Maybe (Maybe.Maybe Int)
  18. ```
  19.  
  20. But I'm having difficulties handling the UUID:
  21. ```
  22. > parsePath (s "admin" </> s "sites" </> string </> s "residents") location
  23. Just "91c2a015-6f2c-47fc-bc76-c136e2401058" : Maybe.Maybe String
  24.  
  25. > parsePath (s "admin" </> s "sites" </> string </> s "residents" <?> intParam "page") location
  26. -- TYPE MISMATCH --------------------------------------------- repl-temp-000.elm
  27.  
  28. The 1st argument to function `parsePath` is causing a mismatch.
  29.  
  30. 6| parsePath (s "admin" </> s "sites" </> string </> s "residents" <?> intParam "page") location
  31. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  32. Function `parsePath` is expecting the 1st argument to be:
  33.  
  34. Parser (String -> String) String
  35.  
  36. But it is:
  37.  
  38. Parser (String -> Maybe Int -> String) String
  39.  
  40. Hint: It looks like a function needs 1 more argument.
  41. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement