Don't Dicts implement Eq-ability? Is there a ticket for it?
This works:
Stdout.line!(Inspect.to_str((Dict.single("A", "B") == Dict.single("A", "B"))))
Can you provide your code?
Oh, it was F64, which doesn't implement Eq
. My bad. The error message was confusing presumingly because of other errors. After I fixed other errors I see a better error message even with a great hint about the reasoning around float not implementing Eq
:
── TYPE MISMATCH in ./RestApi.roc ──────────────────────────────────────────────
This expression has a type that does not implement the abilities it's expected to:
36│ actual == Ok(database)
^^^^^^
I can't generate an implementation of the Eq ability for
[
Err *,
Ok Database,
]
In particular, an implementation for
FloatingPoint ?
cannot be generated.
Note: I can't derive Bool.is_eq for floating-point types. That's
because Roc's floating-point numbers cannot be compared for total
equality - in Roc, `NaN` is never comparable to `NaN`. If a type
doesn't support total equality, it cannot support the Eq ability!
The previous error was:
── TYPE MISMATCH in ./RestApi.roc ──────────────────────────────────────────────
This expression has a type that does not implement the abilities it's expected to:
36│ actual == Ok(database)
^^^^^^
I can't generate an implementation of the Eq ability for
[
Err *,
Ok Database,
]
In particular, an implementation for
?
cannot be generated.
I appritiate the note, but this question mark even here FloatingPoint ?
is not easy to read. Why doesn't the compiler write the type variable instead of the question mark?
I'm not sure, can you share the related block of code?
The compiler uses question mark to point out what is unknown in a type.
If no date is known, just a question mark
If some data is know like they type being a floating point, it adds that info
I think it is mostly done for clarity of new learners
But I don't actually know the original incentives, so that is just a guess.
I'm a bit surprised it is FloatingPoint ?
and not F64
I feel like if I saw FloatingPoint a
or FloatingPoint unknown
, it wouldn't really be clearer than `FloatingPoint ?
. But I guess it would be more familiar as it is still a type variable.
The thing is the full type should have been known in my opinion. It was just F64
. I'll try to find time today and post the code. I've fixed the error, so would need time to reproduce it.
yeah, I would guess it is a big in the output
Even is a simple example like this the compiler doesn't seem to recognise the type and references the type variable as ?
:
expect
a : List F64
a = [1.0]
b : List F64
b = [1.0]
a == b
Error:
── TYPE MISMATCH in ./Delme.roc ────────────────────────────────────────────────
This expression has a type that does not implement the abilities it's expected to:
11│ a == b
^
I can't generate an implementation of the Eq ability for
List (Frac ?)
In particular, an implementation for
FloatingPoint ?
cannot be generated.
Note: I can't derive Bool.is_eq for floating-point types. That's
because Roc's floating-point numbers cannot be compared for total
equality - in Roc, `NaN` is never comparable to `NaN`. If a type
doesn't support total equality, it cannot support the Eq ability!
Why not F64
or at least something like?
FloatingPoint Signed64
^^^^^^^^
I wonder if this was intentional but led to a bad error message accidentally. Like the computer is trying to say it can't generate Eq
for any floating point types and just printing that poorly.
Brendan Hansknecht said:
I wonder if this was intentional but led to a bad error message accidentally. Like the computer is trying to say it can't generate
Eq
for any floating point types and just printing that poorly.
I doubt so. My initial error, which I struggle to reproduce now was just stating ?
without any hints, i.e.:
── TYPE MISMATCH in ./RestApi.roc ──────────────────────────────────────────────
This expression has a type that does not implement the abilities it's expected to:
36│ actual == Ok(database)
^^^^^^
I can't generate an implementation of the Eq ability for
[
Err *,
Ok Database,
]
In particular, an implementation for
?
cannot be generated.
Last updated: Jul 06 2025 at 12:14 UTC