News for hackers. Stuff that matters.
Re:Haskell for Web Developers by mietek on Friday July 26, 2013 @06:15PM (#6110917)
The `StateT` example in the article is unfortunate, as it reinforces the misguided notion that handling state in Haskell requires complicated machinery, such as monad transformers. This is simply false. You can use a mutable reference, like this:

    import Control.Monad
    import Data.IORef

    main = do
      ref <- newIORef 0
      forever $ do
        val <- readLn
        modifyIORef ref (+ val)
        total <- readIORef ref
        putStrLn ("Total: " ++ show total)
Haskell's libraries haven't been designed to make this use case as concise as possible, but nothing prevents you from introducing more succinct notation. To illustrate this point: In Haskell, the `forever` control flow operator is not a language keyword, but a function you could write yourself. In Python, could you write `print` yourself?
Re:Haskell for Web Developers by eurleif on Friday July 26, 2013 @06:17PM (#6110921)
>In Python, could you write `print` yourself?

In Python 3, where print is a function? Yes.

In Python 2, not with exactly the same syntax, but you could certainly write a function to provide the same features.

Re:Haskell for Web Developers by zeckalpha on Saturday July 27, 2013 @11:36AM (#6113273)
A better example would have been `if`.