I am new to elm, and functional programming in general. I was getting a puzzling type mismatch when doing division with a call to 'show'. This code produces the mismatch:
import Graphics.Element exposing (..)
columns = 2
main = placePiece 10
placePiece: Int -> Element
placePiece index =
show (index/columns)
The code produces this error:
Type mismatch between the following types on line 9, column 3 to 22:
Int Float
It is related to the following expression:
show (index / columns)
Which I read to mean that it expects and Int, but got a Float. But show works with any type. If I use floor to force the division into an Int, I get the same error. But, if I hard code the numbers, e.g. show (10/2)
It works fine.
So what part of the code above is expecting to get an Int?