[Haskell-beginners] Can't compile Diagrams tutorial example

Roger Mason rmason at mun.ca
Fri Aug 29 19:37:39 UTC 2014


Hello,

I have the following code from the Diagrams package tutorial:

> {-# LANGUAGE NoMonomorphismRestriction #-}
> 
> import Diagrams.Prelude
> import Diagrams.Backend.SVG.CmdLine

> main = mainWith (example :: Diagram B R2)
> example = circle 1 # fc blue
>                    # lw veryThick
>                    # lc purple
>                    # dashing [0.2,0.05] 0

I get the following error on compilation using GHC 7.6.3:

ghc --make DiagramsTutorial-2.lhs

[1 of 1] Compiling Main             ( DiagramsTutorial-2.lhs, DiagramsTutorial-2.o )

DiagramsTutorial-2.lhs:10:33:
    Could not deduce (Fractional (Measure R2))
      arising from the literal `0.2'
    from the context (TrailLike b,
                      Transformable b,
                      HasStyle b,
                      V b ~ R2)
      bound by the inferred type of
               example :: (TrailLike b, Transformable b, HasStyle b, V b ~ R2) =>
                          b
      at DiagramsTutorial-2.lhs:(7,3)-(10,43)
    Possible fix:
      add an instance declaration for (Fractional (Measure R2))
    In the expression: 0.2
    In the first argument of `dashing', namely `[0.2, 0.05]'
    In the second argument of `(#)', namely `dashing [0.2, 0.05] 0'

DiagramsTutorial-2.lhs:10:43:
    Could not deduce (Num (Measure R2)) arising from the literal `0'
    from the context (TrailLike b,
                      Transformable b,
                      HasStyle b,
                      V b ~ R2)
      bound by the inferred type of
               example :: (TrailLike b, Transformable b, HasStyle b, V b ~ R2) =>
                          b
      at DiagramsTutorial-2.lhs:(7,3)-(10,43)
    Possible fix: add an instance declaration for (Num (Measure R2))
    In the second argument of `dashing', namely `0'
    In the second argument of `(#)', namely `dashing [0.2, 0.05] 0'
    In the expression:
      circle 1 # fc blue # lw veryThick # lc purple
      # dashing [0.2, 0.05] 0

Thanks for any help.

Roger


More information about the Beginners mailing list