Help, how to coerce an Int into a Number?

I’m using the elm Playground package for drawing an SVG.
Applying indexedMap to a list of values I am trying to render shapes and alter the shapes position with the Playground function moveDown : Number -> Shape -> Shape.
The crux of the issue is that this function accepts the Number type and that is somehow incompatible with the Int type?!
What can I do?

module Main exposing (main)

import Playground exposing (..)

main =
    picture view

type Node
    = Node Int (List Int)

view =
        graph =
            [ Node 0 [ 1, 2 ]
            , Node 1 []
            , Node 2 []
        |> Debug.toString
        |> List.indexedMap printDown

printDown : Int -> String -> Shape
printDown i x =
    words black x
        |> moveDown i -- moveDown expects Number, got Int and fails?!

In the playground package, Number is defined as a type alias to Float: Playground - elm-playground 1.0.3

So you need a Float rather than an Int. In this case you could just change the type signature of printDown to be Float -> String -> Shape, or you could use the toFloat : Int -> Float function.


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.