It turns out that the annularWedge
function of the diagrams package cannot take a radius of 0 for the inner radius. You must use wedge
instead.
To me, an inner radius of 0 is just the degenerate case of annularWedge
and should behave like wedge
, so I tried to combine them:
mywedge r2 r1 d a
| r1 == 0 = wedge r2 d a
| otherwise = annularWedge r2 r1 d a
Of course, it doesn't work, and I cannot figure out what the error means:
Non type-variable argument in the constraint: RealFloat (N t)
(Use FlexibleContexts to permit this)
When checking that ‘mywedge’ has the inferred type
mywedge :: forall t.
(RealFloat (N t), TrailLike t, V t ~ V2) =>
N t -> N t -> Direction V2 (N t) -> Angle (N t) -> t
In fact, it turns out that annularWedge
and wedge
have different constraints, which surprised me:
annularWedge :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => n -> n -> Direction V2 n -> Angle n -> t
wedge :: (InSpace V2 n t, OrderedField n, TrailLike t) => n -> Direction V2 n -> Angle n -> t
So how do I combine these two functions into a sane one that accepts an inner radius of 0 and does the right thing?