[Chart] Fwd: [diagrams] Re: [GSoC 2013] Progress - Porting Charts to Diagrams

Jan Bracker jan.bracker at googlemail.com
Mon Jun 10 16:24:34 BST 2013


Hi,

Andy: The goal is to abstract Charts from Cairo so we can plug in another
backend (target is Diagrams). And by that we would also be able to use
Sunroof through diagrams. Of course in the end it should also be possible
to implement a Sunroof backend on its own.

Tim:

 > Rather than have the CRender monad take an extra parameter, I guess one
> could just have a separate data type for each backend (ie CRenderCairo and
> CRenderDiagrams) and have the drawing code abstracted over a typeclass
> implemented by both. Not sure if this would be better...
>

 I tried your approach in a new branch:
https://github.com/jbracker/haskell-chart/tree/backend-experiment

It seems to be working quite well. So I started generalizing everything
outside of the cairo module to use a general ChartBackend m instead of a
CRender to draw everything. There are a few spots that are giving me a hard
time:

Renderable was implemented in terms of CRender. So I added another type
parameter and that worked fine until I hit Legend. There I also added a
type parameter. But that blew up the ToRenderable instance. So I had to
insert a associated type to relate types to each other. After doing so I
was not able to fix whatever went wrong in Plot.Pie. The 'ToRenderable
PieLayout' instance gives me this error:

Graphics/Rendering/Chart/Plot/Pie.hs:121:62:
    Could not deduce (RenderableT m a0 ~ PieChart)
    from the context (ChartBackend m)
      bound by the type signature for
                 toRenderable :: ChartBackend m =>
                                 RenderableT m PieLayout -> Renderable m ()
      at Graphics/Rendering/Chart/Plot/Pie.hs:(117,5)-(125,29)
    The type variable `a0' is ambiguous
    Possible fix: add a type signature that fixes these type variable(s)
    In the return type of a call of `pie_plot_'
    In the second argument of `($)', namely `pie_plot_ p'
    In the second argument of `addMargins', namely
      `(toRenderable $ pie_plot_ p)'

I think I know what is going wrong, but I have no idea how to specify the
instance it should use there. Maybe I am just to tired to see the solution.

Right now I am trying to make things work without extra type parameters,
though the definitions that are based on CRender are giving me a hard time,
because then I end up with rank N types.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://projects.haskell.org/pipermail/chart/attachments/20130610/93045112/attachment.htm>


More information about the Chart mailing list