Skip to content

Instantly share code, notes, and snippets.

@jippi
Created November 24, 2016 11:06
Show Gist options
  • Save jippi/112ffe85c5255ba6a138fb97b5457625 to your computer and use it in GitHub Desktop.
Save jippi/112ffe85c5255ba6a138fb97b5457625 to your computer and use it in GitHub Desktop.
-- TYPE MISMATCH -------------------------------------------------- src/Main.elm
The 7th and 8th entries in this list are different types of values.
45| [ Url.map ListAllocationsRoute Url.top
46| , Url.map ListAllocationsRoute (Url.s "allocations")
47| , Url.map ViewAllocationRoute (Url.s "allocations" </> Url.string)
48| , Url.map ViewAllocationRoute (Url.s "allocations" </> Url.string </> Url.s "info")
49| , Url.map ViewAllocationRoute (Url.s "allocations" </> Url.string </> Url.s "files")
50| , Url.map ViewAllocationRoute (Url.s "allocations" </> Url.string </> Url.s "logs")
51| , Url.map ViewAllocationRoute (Url.s "allocations" </> Url.string </> Url.s "raw")
52|> , Url.map EvaluationListRoute (Url.s "evaluations")
53| , Url.map JobsPage (Url.s "jobs")
54| ]
The 7th entry has this type:
Url.Parser ((String -> Route) -> c) c
But the 8th is:
Url.Parser ((Route) -> c) c
Hint: It looks like a function needs 1 more argument.
Hint: Every entry in a list needs to be the same type of value. This way you
never run into unexpected values partway through. To mix different types in a
single list, create a "union type" as described in:
<http://guide.elm-lang.org/types/union_types.html>
-- TYPE MISMATCH -------------------------------------------------- src/Main.elm
The 2nd and 3rd entries in this list are different types of values.
45| [ Url.map ListAllocationsRoute Url.top
46| , Url.map ListAllocationsRoute (Url.s "allocations")
47|> , Url.map ViewAllocationRoute (Url.s "allocations" </> Url.string)
48| , Url.map ViewAllocationRoute (Url.s "allocations" </> Url.string </> Url.s "info")
49| , Url.map ViewAllocationRoute (Url.s "allocations" </> Url.string </> Url.s "files")
50| , Url.map ViewAllocationRoute (Url.s "allocations" </> Url.string </> Url.s "logs")
51| , Url.map ViewAllocationRoute (Url.s "allocations" </> Url.string </> Url.s "raw")
52| , Url.map EvaluationListRoute (Url.s "evaluations")
53| , Url.map JobsPage (Url.s "jobs")
54| ]
The 2nd entry has this type:
Url.Parser ((Route) -> c) c
But the 3rd is:
Url.Parser ((String -> Route) -> c) c
Hint: It looks like a function needs 1 more argument.
Hint: Every entry in a list needs to be the same type of value. This way you
never run into unexpected values partway through. To mix different types in a
single list, create a "union type" as described in:
<http://guide.elm-lang.org/types/union_types.html>
type Route
= ListAllocationsRoute
| ViewAllocationRoute String String
| JobsPage
| EvaluationListRoute
route : Url.Parser (Route -> a) a
route =
Url.oneOf
[ Url.map ListAllocationsRoute Url.top
, Url.map ListAllocationsRoute (Url.s "allocations")
, Url.map ViewAllocationRoute (Url.s "allocations" </> Url.string)
, Url.map ViewAllocationRoute (Url.s "allocations" </> Url.string </> Url.s "info")
, Url.map ViewAllocationRoute (Url.s "allocations" </> Url.string </> Url.s "files")
, Url.map ViewAllocationRoute (Url.s "allocations" </> Url.string </> Url.s "logs")
, Url.map ViewAllocationRoute (Url.s "allocations" </> Url.string </> Url.s "raw")
, Url.map EvaluationListRoute (Url.s "evaluations")
, Url.map JobsPage (Url.s "jobs")
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment