Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving the mismatched attributes problem. #122

Merged
merged 1 commit into from
Aug 24, 2024

Conversation

PiotrJustyna
Copy link
Contributor

@PiotrJustyna PiotrJustyna commented Aug 23, 2024

First of all, thanks for all your hard work on the library. Here's an issue I found today, wondering what people think about how we should best resolve it.

I propose just a quick/temporary fix to allow people to use this sample, but wanted to PR it anyway to highlight an issue this line produces. Here is what I'm getting while compiling the code in its current shape:

app/Main.hs:31:42: error: [GHC-83865]
    • Couldn't match expected type ‘svg-builder-0.1.1:Graphics.Svg.Core.Attribute’
                  with actual type ‘Lucid.Svg.Attribute’
      NB: ‘svg-builder-0.1.1:Graphics.Svg.Core.Attribute’
            is defined in ‘Graphics.Svg.Core’ in package ‘svg-builder-0.1.1’
          ‘Lucid.Svg.Attribute’
            is defined in ‘Lucid.Base’ in package ‘lucid-2.11.20230408’
    • In the expression:
        Lucid.Svg.preserveAspectRatio_ $ Data.Text.pack "xMinYMin"
      In the ‘_svgAttributes’ field of a record
      In the expression:
        Diagrams.Backend.SVG.SVGOptions
          {_size = Diagrams.Prelude.mkSizeSpec
                     $ Diagrams.Prelude.V2 (Just 400) (Just 400),
           _idPrefix = Data.Text.empty, _svgDefinitions = Nothing,
           _svgAttributes = [Lucid.Svg.preserveAspectRatio_
                               $ Data.Text.pack "xMinYMin"],
           _generateDoctype = True}
   |
31 |   Diagrams.Backend.SVG._svgAttributes = [Lucid.Svg.preserveAspectRatio_ $ Data.Text.pack "xMinYMin"],

Looks like the types are mismatched (if I'm reading the error correctly):

  • _svgAttributes is of type Graphics.Svg.Core.Attribute from package svg-builder

  • preserveAspectRatio_ produces values of type Lucid.Base.Attribute from package lucid

Curious what others think about how this should be best addressed.

I confirm leaving the attributes empty does work and does produce the sample circle.

Copy link
Member

@byorgey byorgey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Probably the code in examples was written a long time ago, and in the meantime we switched from lucid to svg-builder as a backend but no one remembered to update the code in examples. If someone has the motivation to explore how to translate the example more fully, go for it, but for now I agree just emptying the attributes list is the way to go.

@byorgey byorgey merged commit 9161623 into diagrams:master Aug 24, 2024
10 checks passed
@byorgey
Copy link
Member

byorgey commented Aug 27, 2024

Released in diagrams-svg-1.4.3.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants