0

The code

rayTraceP (p2 (0, 0)) (r2 (1, 0)) (circle 1)

causes the error message

 Could not deduce: V a0 ~ V2
      from the context: (Traced a, TrailLike a, Transformable a,
                         V a ~ V2)
        bound by the inferred type for ‘it’:
                   forall a.
                   (Traced a, TrailLike a, Transformable a, V a ~ V2) =>
                   Maybe (Point (V a) (N a))
        at <interactive>:1:1-44
      The type variable ‘a0’ is ambiguous

I can't figure out why this happens. It seems that rayTraceP is used similarly in the manual. I use diagrams-cairo-1.4.1 .

E. Nerush
  • 69
  • 7

1 Answers1

1

This kind of error is usually caused by ambiguous types during type inference, and can be fixed by adding one or more type signatures. In this case I think the problem is most likely that it can't figure out what type the 'circle 1' call should have. If you show all the code I could give some better advice about where to add a type signature.

See section 5.5 of the user manual for more info: https://diagrams.github.io/doc/manual.html#tips-and-tricks

Brent Yorgey
  • 2,043
  • 16
  • 17
  • Thank you for your answer, adding a type signature to `circle 1` solves the problem. The following code works fine (I use ghci, so it is all the code):```rayTraceP (p2 (0, 0)) (r2 (1, 0)) (circle 1 :: Diagram B)``` – E. Nerush Jul 29 '19 at 12:08