You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I am learning diagrams for like 2 days. At first it was smooth sailing, but then I decided to
split some diagram definitions out from the Main module. This is when I met type errors like
these:
src/Draw.hs:10:74: error:
• Couldn't match type ‘V t0’ with ‘V2’
arising from a use of ‘circle’
The type variable ‘t0’ is ambiguous
• In the expression: circle 0.1
In the expression:
let r = (sqrt $ fromIntegral $ Graph.size graph :: Double)
in circle 0.1
In an equation for ‘node’:
node
= let r = (sqrt $ fromIntegral $ Graph.size graph :: Double)
in circle 0.1
• Relevant bindings include node :: t0 (bound at src/Draw.hs:10:5)
I would probably be struggling with them for a lot longer, have I not found this awesome Stack
Overflow answer from Daniel @bergey. In short, there is defined a type synonym like this:
type Back b = (V b ~ V2, N b ~ Double,
Renderable (Path V2 Double) b, Renderable (Text Double) b)
dia2 :: Back b => Diagram b
dia2 = circle 1 # fc blue
I tried it and it actually solves all those type errors!
I understand that this type synonym only covers 2D back ends. But is it not nevertheless awesome?
I propose that type synonyms like this are included in Diagrams.Prelude and written about in the awesome official manual.
The text was updated successfully, but these errors were encountered:
So I am learning
diagrams
for like 2 days. At first it was smooth sailing, but then I decided tosplit some diagram definitions out from the
Main
module. This is when I met type errors likethese:
I would probably be struggling with them for a lot longer, have I not found this awesome Stack
Overflow answer from Daniel @bergey. In short, there is defined a type synonym like this:
I tried it and it actually solves all those type errors!
I understand that this type synonym only covers 2D back ends. But is it not nevertheless awesome?
I propose that type synonyms like this are included in
Diagrams.Prelude
and written about in theawesome official manual.
The text was updated successfully, but these errors were encountered: