Problem compiling an example of the arrows tutorial

25 views
Skip to first unread message

Jorge Devoto

unread,
Apr 28, 2020, 3:53:19 PM4/28/20
to diagrams-discuss
Hello

I was trying to compile the example of a finite state automata in the arrows tutorial. The problem is with
the lines

> text' d s = (strokeP $ textSVG' (TextOpts lin2 INSIDE_H KERN False d d) s)

I get the following error message

graph.hs:16:42: error:
    • Couldn't match type ‘IO
                             (Graphics.SVGFonts.ReadFont.PreparedFont Double)’
                     with ‘(Graphics.SVGFonts.ReadFont.FontData n,
                            Graphics.SVGFonts.ReadFont.OutlineMap n)’
      Expected type: Graphics.SVGFonts.ReadFont.PreparedFont n
        Actual type: IO (Graphics.SVGFonts.ReadFont.PreparedFont Double)
    • In the first argument of ‘TextOpts’, namely ‘lin2’
      In the first argument of ‘textSVG'’, namely
        ‘(TextOpts lin2 INSIDE_H KERN False d d)’
      In the second argument of ‘($)’, namely
        ‘textSVG' (TextOpts lin2 INSIDE_H KERN False d d) s’
    • Relevant bindings include
        d :: n (bound at graph.hs:16:7)
        text' :: n -> String -> QDiagram b V2 n Any
          (bound at graph.hs:16:1)


I am probably doing something wrong. 

Any help is welcomed

Brent Yorgey

unread,
Apr 29, 2020, 7:02:51 AM4/29/20
to Jorge Devoto, diagrams-discuss
Hi Jorge, not your fault!  I think a few types changed in the SVGFonts package.  Most relevant in this case I think is the fact that 'lin2' used to be defined using unsafePerformIO but this was potentially causing problems where the font loading was being performed multiple times.  So now the type of 'lin2' is 'IO (PreparedFont Double)'.  You can add the font as a parameter to your text' function, and load the font in your main function before calling mainWith (or however you are invoking diagrams).  If you need a more complete example I'd be happy to make one, just let me know.

Of course, we should also fix the code in the tutorial!

-Brent


--
You received this message because you are subscribed to the Google Groups "diagrams-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diagrams-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/diagrams-discuss/2e01729a-3017-4d16-a6c6-1b151d6c133a%40googlegroups.com.

Jorge Devoto

unread,
Apr 29, 2020, 8:59:34 AM4/29/20
to diagrams-discuss
Dear Brent.

Thank you for the answer. Could you send me an example? I just want to produce something like the example
in the tutorial.
Best
JOrge


On Wednesday, April 29, 2020 at 8:02:51 AM UTC-3, Brent Yorgey wrote:
Hi Jorge, not your fault!  I think a few types changed in the SVGFonts package.  Most relevant in this case I think is the fact that 'lin2' used to be defined using unsafePerformIO but this was potentially causing problems where the font loading was being performed multiple times.  So now the type of 'lin2' is 'IO (PreparedFont Double)'.  You can add the font as a parameter to your text' function, and load the font in your main function before calling mainWith (or however you are invoking diagrams).  If you need a more complete example I'd be happy to make one, just let me know.

Of course, we should also fix the code in the tutorial!

-Brent


To unsubscribe from this group and stop receiving emails from it, send an email to diagrams...@googlegroups.com.

Brent Yorgey

unread,
Apr 30, 2020, 8:51:41 AM4/30/20
to Jorge Devoto, diagrams-discuss
Hi Jorge,

I am confused.  I went to copy the code in the tutorial to show an example of how to fix it, and it seems like it is already fixed!  In particular, it does not have

> text' d s = (strokeP $ textSVG' (TextOpts lin2 INSIDE_H KERN False d d) s)
>

like you said in your original message; instead it defines

> text' font d s = (strokeP $ textSVG' (TextOpts font INSIDE_H KERN False d d) s)
>                # lw none # fc black

and then later it defines
> example = do
>   font <- lin2
>   return $ states font
>     ...
Aha, wait, I think I know what is going on.  Are you looking at


The correct URL for the most up-to-date version of the diagrams site is


How did you find the old version?  Ideally we should get rid of it but I'm not sure how to do that.  I thought all the relevant links had been updated but there are surely still old links floating around...

-Brent


To unsubscribe from this group and stop receiving emails from it, send an email to diagrams-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/diagrams-discuss/e9b33f2d-ed49-4d90-a82d-9a3644f8aa53%40googlegroups.com.

Sylvain Henry

unread,
Apr 30, 2020, 9:41:23 AM4/30/20
to diagrams...@googlegroups.com

I didn't know about the new site either. DDG still reports the archived one:

Cheers,
Sylvain

Brent Yorgey

unread,
Apr 30, 2020, 10:03:09 AM4/30/20
to Sylvain Henry, diagrams-discuss
Hmm, you're right, and in fact, all the .cabal files still point to the old location as well!

Now that I think about it, I thought I remembered setting up a redirect so the old site pointed to the new one.  But obviously it is not working anymore (if it ever did, which is unclear).  I will try to get this sorted out!

-Brent

Jorge Devoto

unread,
Apr 30, 2020, 10:04:48 AM4/30/20
to diagrams-discuss
--
You received this message because you are subscribed to the Google Groups "diagrams-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diagrams...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "diagrams-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diagrams...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages