[Haskell-cafe] Is there a way to make this code compose generic ?
PICCA Frederic-Emmanuel
frederic-emmanuel.picca at synchrotron-soleil.fr
Fri Apr 25 08:07:09 UTC 2025
----- Le 24 Avr 25, à 22:41, Li-yao Xia lysxia at gmail.com a écrit :
> You can delegate to another class that has a default implementation
>
> instance GDSAK1 a => GDataSourceAcq (K1 i a) where
> g'ds'Shape (K1 a) = g'ds'Shape'K1 a
>
> class GDSAK1 a where
> g'ds'Shape'K1 :: ...
> g'ds'Shape'K1 _ = pure shape1
>
> instance GDSAK1 (a DSAcq) where
> g'ds'Shape'K1 = ...
>
> instance GDSAK1 Degree
> instance GDSAK1 Double
> ...
>
> You can also use an overlappable instance to not list all the instances,
> but the downside is you don't get an error if you forget to override it.
I prefer the first solution. I use haskell for the compiler errors :)
Do you know if there is some performance issue to use a new class for this ?
How can I be sure that all the method are statically resolve at the compile time ?
I do not know If I am clear.
thanks
Fred
More information about the Haskell-Cafe
mailing list