Closed alfert closed 5 years ago
Yes, unfortunately comparing functions is a limitation in most languages. You need to apply a function to get a value, and compare those. I've run across this in a few places in Algae (ex. State). There are two workarounds:
@force_type_instance true
, and test the properties elsewhereI recommend the second one, most for pragmatism. You'll get a warning message during compilation that automatic prop testing is being overwritten, but the instance will be lawful if your manual tests pass.
I am implementing a
Witchcraft.Functor
, having an unary function as data inside a struct:The
Functor
'smap
function is implemented asThe property testing of
Functor
fails because the struct is compared and the functional values are different by definition of Erlang/Elixir (which is the reason whyequals
implements specific comparison method).Is this the case for
@force_type_instance true
, is this a bug ofequals
(where it could be useful to define aequal
function the type class instance) or am I missing an alternative approach?