You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an error similar to what I encountered while trying to implement a linearspace typeclass on top of Witchcraft.Monoid.
Here is a minimal example to reproduce the issue:
# -- type_class_check.ex --## HOW TO USE:# From iex, enter these lines (minus the prompt)# # iex> Mix.install([ {:witchcraft, "~> 1.0"}, {:type_class, "~> 1.2"} ])# :ok# iex> c "type_class_check.ex"importTypeClassdefclassSomeClassdoextendWitchcraft.MonoidaliasWitchcraft.Semigroupwheredodefmerge(arg1,arg2)endpropertiesdodefcommutativity(data)doa=generate(data)b=generate(data)Semigroup.append(a,b)==Semigroup.append(b,a)endendenddefinstSomeClass,for: Integerdo# custom_generator(data) do# data |> IO.inspect()# enddefmerge(arg1,arg2)doarg1*arg2endend
This should compile without problem, as expected.
However uncommenting the custom generator will reveal all the different sort of data that is passed to it. It doesn't match the current implementation (Integer) as I would have expected...
I was actually trying this as a simple workaround for #19 ...
Now I am guessing the error is related to this package and the design of custom_generator, but I am not used to type_class, so feel free to let me know if I am just holding this wrong, or if I should post this somewhere else (witchcraft itself ?).
Cheers !
The text was updated successfully, but these errors were encountered:
Try it and see if it works. It doesn't know that you're defining some instance for an Integer, but if you give it a sample of the datatype you're working with, it should dispatch correctly.
In general, that's how a lot of things are treated in Witchcraft library family: by sampling!
This is an error similar to what I encountered while trying to implement a linearspace typeclass on top of
Witchcraft.Monoid
.Here is a minimal example to reproduce the issue:
This should compile without problem, as expected.
However uncommenting the custom generator will reveal all the different sort of data that is passed to it. It doesn't match the current implementation (Integer) as I would have expected...
I was actually trying this as a simple workaround for #19 ...
Now I am guessing the error is related to this package and the design of custom_generator, but I am not used to
type_class
, so feel free to let me know if I am just holding this wrong, or if I should post this somewhere else (witchcraft itself ?).Cheers !
The text was updated successfully, but these errors were encountered: