# How to test run elm/url in REPL?

**URL:** <https://discourse.elm-lang.org/t/how-to-test-run-elm-url-in-repl/2596>\
**Category:** Learn\
**Created:** [November 23, 2018, 2:55am UTC](https://discourse.elm-lang.org/t/how-to-test-run-elm-url-in-repl/2596 "2018-11-23T02:55:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yiwei](https://avatars.discourse-cdn.com/v4/letter/y/2bfe46/32.png) [@yiwei](https://discourse.elm-lang.org/u/yiwei)\
**Post date:** [November 23, 2018, 2:55am UTC](https://discourse.elm-lang.org/t/how-to-test-run-elm-url-in-repl/2596/1 "2018-11-23T02:55:56Z")

</div>

Hi,  
I’m just an Elm beginner. And now I’m trying to test elm/url in REPL, I did the following steps:

myParser = s “foo”  
myUrl = { fragment = Nothing, host = “[foo.com](http://foo.com)”, path = “#foo”, port\_ = Nothing, protocol = Http, query = Nothing }

Now I try this in REPL:  
Parser.parse myParser myUrl

And bang, I got infinite types error, no idea what I did wrong, so could anyone please give me a hint? Thank you.

---

<div class="post-metadata">

**Author:** ![malaire](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@malaire](https://discourse.elm-lang.org/u/malaire)\
**Post date:** [November 23, 2018, 6:17am UTC](https://discourse.elm-lang.org/t/how-to-test-run-elm-url-in-repl/2596/2 "2018-11-23T06:17:51Z")

</div>

The following steps works in `elm repl`:

```auto
import Url
import Url.Parser as Parser
myParser = Parser.map "GotFoo" (Parser.s "foo")
myUrl = { fragment = Nothing, host = "foo.com", path = "/foo", port_ = Nothing, protocol = Url.Http, query = Nothing }
Parser.parse myParser myUrl

```

Your `myParser = s "foo"` is of type `Parser a a` when `parse` requires first parameter to be of type `Parser (a -> a) a`. Basically you need a parser which returns something from successful parse.

For example you can use `myParser = Parser.map "GotFoo" (Parser.s "foo")` which maps return value you want to actual parser. I used a `String` value `"GotFoo"` here to make example simple but usually you would use some custom type instead.

Parser like `myParser = Parser.s "foo" </> Parser.int` will also work as it has return value. This one parses a path like `/foo/123` and then returns that `123`.

ps. `"#foo"` is not valid path, so I fixed that to `"/foo"` in your example.

---

<div class="post-metadata">

**Author:** ![yiwei](https://avatars.discourse-cdn.com/v4/letter/y/2bfe46/32.png) [@yiwei](https://discourse.elm-lang.org/u/yiwei)\
**Post date:** [November 23, 2018, 6:54am UTC](https://discourse.elm-lang.org/t/how-to-test-run-elm-url-in-repl/2596/3 "2018-11-23T06:54:15Z")

</div>

Hi malaire, thank you so much, now I understand why my code is not working.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [December 3, 2018, 6:54am UTC](https://discourse.elm-lang.org/t/how-to-test-run-elm-url-in-repl/2596/4 "2018-12-03T06:54:16Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
