[Chart] A bunch of features and fixes.

Tim Docker tim at dockerz.net
Thu Feb 2 12:42:58 GMT 2012


> 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
>
> where the AxisOptions type includes Boolean flags to choose whether 
> each axis is linear or log.  As things currently stand, without a 
> class method it is impossible to write, because autoScaledLogAxis only 
> works for RealFloat values, not for PlotValues.  I understand of 
> course that e.g. an Indexed axis is not going to be able to implement 
> the log scale properly, but in that case, it would be OK for its 
> instance simply to use a linear scale despite the name of the option.

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.

I see that if you want the type signature above you really have to do 
this. 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

??

Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://projects.haskell.org/pipermail/chart/attachments/20120202/cd81f726/attachment.htm>


More information about the Chart mailing list