hi I am writing few functions to operate on matrices here https://github.com/salarii/roc_play/blob/main/Matrix.roc . It seems I need two "configurations" to cope with complex and Frac separately(btw. in some languages there would be one "configuration" and implementation for all of them but I can't figure out how to do this in Roc).
It is very disheartening that apparently I can't create one instance of "configuration" and provide it directly inside of every function as needed. Apparently I need to copy paste the same thing over and over. I am talking "opFrec" and "opComplex" which I consider the configurations here
Hi Artur :)
This seems like something suited for Abilities.
See this example to learn how to implement your own Ability.
thx Anton, it looks like I could try this, but anyway why I have to repeat opComplex or opFrec every time. Seems to me like a bug
Not sure if this is the issue or not, but this type looks incorrect:
opFrec : OperationType (Frac a)
Shouldn't it be:
opFrec a : OperationType (Frac a)
Same with the complex ops.
Also yeah, what you are trying to do definitely should work.
@Brendan Hansknecht you overlooked that those guys are not types, they are instances of something. Anyway when I try to assign them to "op" directly there are compilation errors. Anyway when I will have more time I will try abilities
Ah, yeah.
So I think this is a unification bug. Given the types print out as identical, I assume this is equivalent to #beginners > Puzzling type error
A workaround is to make opComplex
and opFreq
lazily generated
Might also need to comment out the type
So change the definition to opComplex = \{} -> ...
Last updated: Jul 06 2025 at 12:14 UTC