5 ms·
Alice ML: val (page1, page2, page3) = (spawn getURL "url1", spawn getURL "url2", spawn ge
by doublec 11y ago
Alice ML:
val (page1, page2, page3) = (spawn getURL "url1",
spawn getURL "url2",
spawn getURL "url3")
The requests are concurrent. Spawn returns a future and 'page1', etc are futures immediately. When the value of 'page1', etc is requested later the requesting process either blocks until the getURL for that value is complete, or transforms into the value implicitly if it's already done.
I think it's just as nice as the Haskell example. I do agree that Haskell is a great language though.
- purescript 11y agoI don't know Alice ML but one advantage of using abstractions like Applicative is that you can write code which is polymorphic in the particular applicative you choose. So, you can mock your concurrent requests using the Identity or ZipList applicative, and use the type class laws to prove things which are true about both. I'm guessing, but it looks like the spawn syntax is built-in here. Not that it's not as elegant as the Concurrent version, but likely not as powerful from an abstraction point of view.
- doublec 11y agoCorrect, spawn is built in in Alice ML. Haskell wins on all the ways it can be used beyond built in functionality compared to it.
- deleted 11y ago[deleted]