4 ms·
Elm 0.15: Asynchrony with Tasks
- thomasweiser 12y agoRelease of new version of Elm (A functional reactive language for interactive applications) "This release introduces tasks, a way to define complex asynchronous operations. Similar to C#’s tasks and JavaScript’s promises, tasks make it simple to describe long-running effects and keep things responsive. They also provide a way to wrap up tons of browser APIs in Elm."
- rudi-c 12y agoThis is awesome. Dealing with HTTP requests used to be a pain since they were all signals even when they were used only once, which was not intuitive. This should make the language much more usable.
- nijiko 12y agoI prefer the backcalls of LiveScript to any implementation I have seen thus far, coupled with do, you can do some pretty complex things
- johnpmayer 12y agoThere's probably going to be something like do-notation in Elm 0.16.
- CMCDragonkai 12y agoAren't promises just a monad?
- RehnoLindeque 12y ago(Task x) has monadic structure, yes (see andThen, succeed). Naturally it also looks like Functor, Applicative, etc. However, there is no way to work with monads in the abstract in Elm (yet), there is only the concrete API.
- CMCDragonkai 12y agoIf it has those primitives, why not just wrap them up into a bind operator?
- kailuowang 12y agoCongratulations to the Elm team! As a side note scala-js provides an interesting alternative. In the new Principles of Reactive Programming, https://class.coursera.org/reactive-002/assignment https://class.coursera.org/reactive-002/assignment, a decent RFP example using scalajs was given.
- taylorfausak 12y agoThe decisions the Elm team make continue to impress me. I like that they are willing to break from tradition in order to create a better programming environment. In particular, changing the head function to be total is a great move. head : List a -> Maybe a Compare that with the same function in Haskell. head :: [a] -> a To me, the Elm version makes more sense. (It also avoids having to explain that "[a]" means "list of 'a's".)
- lisperforlife 12y agoIn addition to the lexical change, the result now returns a Maybe instead of the actual element. This was done to avoid runtime crashes when head encounters an empty list. However, this means that everytime you have to use head, you will have to pattern match on Just x/Nothing to consume it. However, you can still use the (x::xs) pattern matching syntax to obtain head and tail and pattern match on [] for empty lists. Absence of applicatives or monads mean that you have to explicitly pattern match on Just/Nothing everytime. There is a proposal to add `?` as an operator to obtain the head of the list without the Maybe and provide a default value if it is Nothing. Also there is another proposal to allow `unsafe` for the program to crash if the result is Nothing.
- dragonwriter 12y ago> Absence of applicatives or monads mean that you have to explicitly pattern match on Just/Nothing everytime. It seems to me that most real uses can probably be solved by map, and withDefault if you really need to get out of the Maybe monad for some reason (though map should make it so that you don't have to for most things.) > There is a proposal to add `?` as an operator to obtain the head of the list without the Maybe and provide a default value if it is Nothing. Since elm supports user-defined operators, can't you just do that yourself. Something like: list ? default = withDefault default (head list)
- rtfeldman 12y agoYep! The proposal is to add that to the core libraries, and is basically just waiting to see how much people actually want to use withDefault that way in practice.
- habitue 12y agoWho isn't a fan of Elm? This language keeps impressing me.
- toomim 12y agoLots of people don't get it, and thus aren't fans. It seems like lots of people in the functional community are fans. I spent some time trying to get it, and I got part of it, but I'm not yet a fan.
- ams6110 12y agoThat page is really tough to read on a phone.
- moomin 12y agoElm is lovely, but it really needs typeclasses.