Giter Club home page Giter Club logo

Comments (5)

process-bot avatar process-bot commented on July 19, 2024

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

from svg.

jvoigtlaender avatar jvoigtlaender commented on July 19, 2024

Where do you see that error message? I don't think it actually occurs for the program you claim it is occurring for? At least, on http://elm-lang.org/try the test program

import Svg exposing (..)
import Svg.Attributes exposing (..)

type Msg = Msg

drawNum : Int -> Svg Msg
drawNum num = 
    text' [ x 30, y 30 ] [ text (toString num) ]

gives a completely different message than the one you show.

from svg.

rhetr avatar rhetr commented on July 19, 2024

oh I see, I wasn't properly declaring type Msg = Msg. I'm still getting the error I mentioned using this code:

import Html exposing (div, h1)
import Svg exposing (..)
import Svg.Attributes exposing (..)

type Msg = Msg

posX : Float -> Float -> Float
posX angle len =
    50 + len * sin angle

posY : Float -> Float -> Float
posY angle len =
    50 - len * cos angle

drawNum : Int -> Svg Msg
drawNum num =
    let
        angle = 2 * pi  * num / 12
        len = 40
    in
        text'
            [ x (posX angle len |> toString)
            , y (posY angle len |> toString)
            ] [ text (toString num) ]

main = 
  div [] 
  [ h1 [] [ text "test" ]
  , svg []
  [ drawNum 3 ]
  ]

I think the problem might be in the angle = 2 * pi * num / 12 ? Does num get automatically cast as a Float because of this even though it is usually an int?

from svg.

jvoigtlaender avatar jvoigtlaender commented on July 19, 2024

Okay, that's completely different code, and the reason that the compiler is saying you are confusing Int and Float is because that's what you are doing. In drawNum you declare num to be an Int, but then multiply it with pi. You cannot multiply an Int with pi, because pi is a Float.

So what you have is a true type error in your code. It's not a bug of compiler or library.

I suggest to close the issue.

from svg.

rhetr avatar rhetr commented on July 19, 2024

thanks

from svg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.