evancz/Elm — pull request #165 by A1kmm (2013-06-03 07:54:20+00:00)
Title: Support type annotations in let

Support type annotations on let. For example, the following typechecks with the patch:

```
red = rgb 255 0 0
hexagon r = ngon 6 r

floatModulo base v =
let basedv = v / base
in
(basedv - toFloat (floor basedv)) * base

currentAngle = (degrees . (\v -> v * 100) . floatModulo 3.6 . inSeconds) <~ (every (50 * millisecond))

main : Signal Element
main =
let
x : Signal Element
x = (\angle -> collage 640 480
[rotate angle
(filled red (hexagon 30))
-- , toForm (plainText (show angle))
]) <~ currentAngle
in
x
```

Changing the x : Signal Element to x : Signal Int causes typechecking to fail as expected.

To implement this, I used Uniplate in a few places, as it makes the code to find all the let bindings much more succinct.