The order of actual and expected
I put your code in the online editor and it gave me a lot of expected/actual is Int/Float errors. I think that's something that can be improved, but that's for the mailing list.
What you should know is that the expected/actual types that the compiler tells you about can sometimes be reversed, at least to some peoples intuitions.
Debugging the problem
To debug this problem I first read and tried to understand your code. The code is simple enough, but the goal of the program wasn't immediately clear to me. Anyway that way I didn't spot anything out of the ordinary. I focussed specifically on the code line in main where the compiler said the type error was, but that didn't seem the source of the problem.
Adding type annotations
So I went ahead and added type annotations to the functions that didn't have any yet. Usually the compiler can give you a better pinpointed position when you add more type annotations.
I added:
render: (Int,Int) -> Tracker -> Element
main : Signal Element
toFloatT: (Int,Int) -> (Float,Float)
roundF: Float -> Float
The problem
The compiler was then able to tell me that the error was in the render function. There I noticed that you made floating point values of the window dimensions and didn't use them, and after that used the integers x
and y
of the Tracker
in a tuple in move
. And there lies the error, because move
takes a tuple of floating points.
The solution
So when you use the following adapted render function, things compile:
render: (Int,Int) -> Tracker -> Element
render (w',h') trk =
let trkPos = toFloatT (trk.x, trk.y)
in collage w' h'
[ngon 3 20 |> filled green
|> move trkPos
, asText (trk.th) |> toForm]
I hope by showing you my way of debugging this type error, you can more easily find a solution next time.
TL;DR
The problem is the render
function: you give the move
function a tuple of Int
s in stead of the tuple of Float
s it expects. The fixed and compiling code can be found here.