Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dates are not comparable #1482

Closed
rigdern opened this issue Sep 8, 2016 · 3 comments
Closed

Dates are not comparable #1482

rigdern opened this issue Sep 8, 2016 · 3 comments

Comments

@rigdern
Copy link

rigdern commented Sep 8, 2016

I tried sorting a list of Dates but got an error due to them not being comparable. Here's some code that produces this error:

import Html exposing (text)
import Date

dateList : List Date.Date
dateList =
  []

sortedDateList =
  List.sort dateList

main =
  text "Hello"

I expected this to compile but instead I got this compiler error:

Detected errors in 1 module.


-- TYPE MISMATCH ---------------------------------------------------------------

The argument to function `sort` is causing a mismatch.

10|   List.sort dateList
                ^^^^^^^^
Function `sort` is expecting the argument to be:

    List comparable

But it is:

    List Date.Date

Hint: Only ints, floats, chars, strings, lists, and tuples are comparable.

I'm using elm 0.17.1.

@process-bot
Copy link

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@JoeyEremondi
Copy link
Contributor

JoeyEremondi commented Sep 8, 2016

You can use this comparison function with this sorting function.

That won't help you if you want to put them as keys in a Dict, though.

@evancz
Copy link
Member

evancz commented Sep 21, 2016

Added to meta issue #1008, thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants