[Chart] A bunch of features and fixes.

Malcolm Wallace malcolm.wallace at me.com
Sun Feb 5 18:51:05 GMT 2012


On 2 Feb 2012, at 12:42, Tim Docker wrote:

> 
>> What I am trying to do, is to implement a function with this polymorphic signature:
>> 
>> overlayPlots :: (PlotValue x, PlotValue y)  => [Plot x y] -> AxisOptions x y -> Layout1 x y
> 
> Currently log  axes are "type safe", in the sense that if you request a log axis, you either see a log axis or if it's not possible to do have a log axis over your type, you get a compile time error. You are proposing to "weaken" this, in the sense that, after your change, you can ask for a log axis for any type, but it will ignore the request for types other than Double.

Yes, that is a reasonable summary.  Of course, log axes are also possible for Int, Integer, and maybe LocalTime (although I have not specifically thought about how one might aesthetically arrange the latter).

> But must the function work exactly this way? You could leave the log related flags out of the AxisOptions structure, and control it with a couple of functions, ie:
> 
> withLogXAxis :: (RealFloat x) =>  Layout1 x y -> Layout1 x y
> withLogYAxis :: (RealFloat y) => Layout1 x y -> Layout1 x y

I'll think about whether that is possible in my setting.  It still requires different code for different types, which is what I am trying to avoid.  But perhaps I could have my own private

    class PlotValue a => LogScale a where autoLogAxis :: AxisFn a

which would keep the type-weakening as part of my own application, without affecting the Chart library itself.

Regards,
    Malcolm



More information about the Chart mailing list