Hacker Newsnew | past | comments | ask | show | jobs | submit | neukoelln's commentslogin

> Monads exist because because haskell people want to pretend that there is this ideal mathematical world where things dont change

Monads exist independently from Haskell and are not about "things that change".


What's imperative about monads? Or rather, what is not functional? Why should they be avoided?


Look at any do block in Haskel, PureScript, Idris etc. It is the imperative code. The individual effects are typed and separated, but it is still the code that depends on implicit state with all its drawbacks.

Then look at Elm code. Elm does not have any imperative hatches. The monad that runs everything is at the very top level (“shell” as the article calls it) and hidden.

As such Elm code is forced to use functional decomposition resulting in very easy to follow, refactor and maintain designs.


Its still quite different than classic imperative code

If you're working with a free monad, or if you don't specify IO (just some of the generic IO like typeclasses like say MonadError), you can still choose your own interpreter for the monad and "program" the semicolon. Which means you get back all the benefits of testability etc.

To get a similar effect in an imperative language, you would use e.g. coroutines and `yield` every side effect to the execution engine. The engine will take the action "specs" (probably a data structure describing the action to perform, e.g. set some value in memory) and decide what to do with them, and you can swap the real engine with a test/mock engine in your tests.


Programming semicolon is not different from mocking interfaces with imperative code. One still has to write it and tests still do not test the real interfaces. Surely the situation is improved compared with imperative code, but it is not as good as with monad-free code.

It is pity that modern conveniences like polimorphic record types with nice syntax for record updates were not invented earlier. With those even with complex code monads can be used only at the top level when the sugar of do blocks is not even necessarily.


Do-notation is Haskell is purely syntactic sugar over function calls. You can remove do-notation from Haskell and still write the exact same programs (with monads and all). Also, monads are not about state anymore than classes in Java are about Toasters.


Surely a do-block is just sugar for the functional code. But that code can be used to model all imperative effects. As such the code inevitably models all troubles the imperative code can cause.

If one looks at the desugared version one can see where the trouble comes. Functional code using monadic style depends on the state of the monad interpreter that can be arbitrary complex and spread over many closures with many interdependencies. It can be rather hard to uncover what exactly is going on, precisely in the same way as with imperative code it models.


You can add

* https://github.com/zalando/grafter

to your list.


And you will also get a stack overflow for free.


In some languages the "stack" may grow until all memory is exhausted.

(Some of those languages also guarantee tail call elimination.)


How is it 25 MP? 4096 × 2160 pixels = 8.8 MP.


Oh, oops, I thought 4k referred to the vertical resolution. In that case, yeah, film possibly has a bit more resolution still.


If you do that for three colors separately that is around 25MP.


Wow, I'm on my second battery for my T430s and about to replace it soon. Battery life is < 1 hour, even with a new one I usually wouldn't get more than three hours. :-(


I'm on a T430s too and battery life is still quite good after nearly four years on the first one (I foolishly had it plugged in most of the time which has brought the capacity down to about 80%). I gave it an additional battery in the Ultra Bay that extends overall battery life to over nearly 5 hours of light use under Linux.


Well, I bought it refurbed about a year ago, it's very likely they replaced the battery at some point.


Greetings from a fellow KIT CS alumnus.


Twitter have not abandoned Scala.


It's also very overpriced. I just moved into a new apartment and I am paying 9€/sqm cold in a very central location. This is very cheap. 11-14€ is more realistic, but even with utilities included you would never have to pay 24€/sqm.


I think Ron Gilbert uses Squirrel in his upcoming game Thimbleweed Park.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: