News for hackers. Stuff that matters.
Re:First Class Statements by shasta on Sunday May 17, 2015 @04:44PM (#9561638)
This isn't exactly true. For example, the article names declaration and assignment as among "statements", but such statements are not first class in Haskell. Nor are type, data, type class statements, etc. It is true that Haskell manages to accomplish many things with expressions that you'd use statements for in other languages.
Re:First Class Statements by tel on Sunday May 17, 2015 @08:19PM (#9562311)
Agreed, but there's a pretty straightforward distinction between statements amenable to becoming values and those that aren't. Essentially, those which control and define the type theory are out of scope as well as those which introduce bindings.
Re:First Class Statements by dllthomas on Sunday May 17, 2015 @09:21PM (#9562467)
I hope that "not amenable to becoming values" is a transient state...
Re:First Class Statements by tel on Monday May 18, 2015 @02:15PM (#9565995)
I'm not sure how I feel about it honestly. I suppose in a dependently typed language there'd be some allowance for `IO Type`.
Re:First Class Statements by wz1000 on Monday May 18, 2015 @04:37AM (#9563331)
I wouldn't call them statements because they aren't executed. Instead, I would classify them as "declarations". You state what something is, instead of telling the computer what to do.

Traditional assignment is an expression in Haskell.

    count :: Int -> IO Int
    count n = do r <- newIORef 0
                 loop r 1
           where 
             loop :: IORef Int -> Int -> IO Int
             loop r i | i>n       = readIORef r
                      | otherwise = do v <- readIORef r
                                       writeIORef r (v+i) 
                                       loop r (i+1)