Warning: calling polyEqual

'a means “any type”, while ''a means “any type that can be compared for equality”. Since your alreadyVisited function compared x and v using =, x and v need to have a type that supports comparing them for equality, so you get the type ''a.

The warning means that you’re comparing two values with polymorphic type for equality.

Why does this produce a warning? Because it’s less efficient than comparing two values of known types for equality.

How do you get rid of the warning? By changing your function to only work with a specific type instead of any type.

Should you care about the warning? Probably not. In most cases I would argue that having a function that can work for any type is more important than having the most efficient code possible, so I’d just ignore the warning.

Leave a Comment