Closed goldfirere closed 10 years ago
I agree that we make monomorphic things more accessible to the users, so that units
will be more available to non-experts. Moreover, isn't that even better if polymorphic ones are equally as accessible as the monomorphic ones?
For example, the type of 1/3
is
:t 1/3
1/3 :: Fractional a => a
while print $ 1/3
appears to choose a specific instance for a
, namely Double
.
I'm wondering how it is achieved and if the mechanism can be applied to our current problem, so that #
and %
are polymorphic and they choose DefaultLCSU
when case of ambiguity. Is there something like default type instance declaration mechanism to Haskell?
Five minutes of thinking has yielded no way to do this. The Haskell Report actually defines the defaulting behavior that you reference, and it's quite a limited facility. See here.
The closest I can come to emulating this behavior is with -XIncoherentIInstances
somewhere, but I think that this extension, when used to get defaulting, brings a real danger of misbehavior.
I'd welcome a good answer here, but I think we're stuck with having two different term-level operators.
One possible way forward is to have Data.Metrology.Mono and Data.Metrology.Poly and then the operators could have the same name. Is that better than the current design? Perhaps. Perhaps not. If we went with this idea, I would want Data.Metrology to re-export the Mono bindings, like how Data.Metrology.SI re-exports Data.Metrology.SI.Mono.
Ok, then I'm agreed to swap #
with ##
and so on.
(I've made this decision much earlier, but I forgot to write here because the Shonan meeting is so exciting.)
Well Richard, do you want to do the implementation since I'll be in the meeting for some few days? I'll be back in June.
I'm happy to do this, but I'm favoring the Data.Metrology.Mono
vs. Data.Metrology.Poly
approach.
Ok! Then let's do the Data.Metrology.Mono
& Data.Metrology.Poly
approach.
Right now,
##
is monomorphic while#
is polymorphic. This goes against the general design of making the monomorphic things more accessible than polymorphic things, as non-experts will want the monomorphic ones.(Suggested by João Cristóvão)