3 ms·
>However, can someone please tell me why Elm needs two kinds of values? Because not all values depend on/change with time. A euclidean distance function is th
by davexunit 12y ago
>However, can someone please tell me why Elm needs two kinds of values?
Because not all values depend on/change with time. A euclidean distance function is the same no matter when in time it exists. But, the distance between a player and an enemy is something that changes with time. So, you'd want to lift the euclidean distance function onto a signal like 'lift2 distance playerPos enemyPos'. I don't actually program in Haskell or Elm, so I don't know if that is the correct syntax, but you get the idea.
- AlexanderDhoore 12y agoBut why not make the "lifting" implicit? If you put a signal into "distance", you get a signal back.
- davexunit 12y agoMaybe it's just me, but that sounds very confusing.
- pseudonom- 12y agoThat sort of unprincipled, implicit conversion is generally frowned upon (by Elm, Haskell, ML, &c.). It reduces type safety. If all you want is syntactic sugar, Elm has infix lift operators so: let p = lift2 (+) Mouse.x Mouse.y becomes: let p = (+) <~ Mouse.x ~ Mouse.y If you don't like that, Haskell has `do` notation. If Elm also had it, you could do: let p = do x <- Mouse.x y <- Mouse.y return (x + y)
- deadfoxygrandpa 12y agoThere was a discussion about this on the Elm mailing list: https://groups.google.com/d/topic/elm-discuss/PNtOH2CDHZo/discussion https://groups.google.com/d/topic/elm-discuss/PNtOH2CDHZo/di...