Click here to Skip to main content
15,896,201 members

The Insider News

   

The Insider News is for breaking IT and Software development news. Post your news, your alerts and your inside scoops. This is an IT news-only forum - all off-topic, non-news posts will be removed. If you wish to ask a programming question please post it here.

Get The Daily Insider direct to your mailbox every day. Subscribe now!

 
GeneralRe: Scala is the new golden child Pin
Super Lloyd14-Jun-16 12:47
Super Lloyd14-Jun-16 12:47 
GeneralRe: Scala is the new golden child Pin
raddevus14-Jun-16 15:55
mvaraddevus14-Jun-16 15:55 
GeneralRe: Scala is the new golden child Pin
Sander Rossel14-Jun-16 21:32
professionalSander Rossel14-Jun-16 21:32 
GeneralRe: Scala is the new golden child Pin
Rob Grainger14-Jun-16 22:28
Rob Grainger14-Jun-16 22:28 
GeneralRe: Scala is the new golden child Pin
Super Lloyd15-Jun-16 4:05
Super Lloyd15-Jun-16 4:05 
GeneralRe: Scala is the new golden child Pin
Sander Rossel15-Jun-16 11:04
professionalSander Rossel15-Jun-16 11:04 
GeneralRe: Scala is the new golden child Pin
Super Lloyd15-Jun-16 12:26
Super Lloyd15-Jun-16 12:26 
GeneralRe: Scala is the new golden child Pin
Rob Grainger15-Jun-16 23:07
Rob Grainger15-Jun-16 23:07 
That's where Monads come in in Haskell.

The IO monad wraps a computation and allows it to have side effects (writing/reading).

getLine = do c <- getChar
             if c == '\n'
                then return ""
                else do l <- getLine
                    return c : l


Most of that is obvious, it reads individual characters and builds up the line (a list of Char) using the ':' operator (the list constructor - 'a' : "bc" is "abc".

It effectively gives you a small imperative sub-language, but retains functional purity. A benefit of this is that side-effects are localised.

It will be evident from the signature of getLine:

getLine :: IO String


That these side-effects are present.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.

GeneralRe: Scala is the new golden child Pin
Sander Rossel16-Jun-16 1:59
professionalSander Rossel16-Jun-16 1:59 
GeneralRe: Scala is the new golden child Pin
Rob Grainger16-Jun-16 5:00
Rob Grainger16-Jun-16 5:00 
GeneralRe: Scala is the new golden child Pin
Rob Grainger15-Jun-16 22:58
Rob Grainger15-Jun-16 22:58 
GeneralRe: Scala is the new golden child Pin
Super Lloyd16-Jun-16 5:18
Super Lloyd16-Jun-16 5:18 
GeneralRe: Scala is the new golden child Pin
Rob Grainger16-Jun-16 9:20
Rob Grainger16-Jun-16 9:20 
AnswerRe: Scala is the new golden child Pin
Super Lloyd14-Jun-16 13:02
Super Lloyd14-Jun-16 13:02 
AnswerRe: Scala is the new golden child Pin
Rob Grainger14-Jun-16 22:27
Rob Grainger14-Jun-16 22:27 
GeneralRe: Scala is the new golden child Pin
raddevus15-Jun-16 3:26
mvaraddevus15-Jun-16 3:26 
GeneralRe: Scala is the new golden child Pin
Kevin McFarlane16-Jun-16 1:31
Kevin McFarlane16-Jun-16 1:31 
GeneralRe: Scala is the new golden child Pin
Rob Grainger16-Jun-16 5:03
Rob Grainger16-Jun-16 5:03 
GeneralRe: Scala is the new golden child Pin
Kevin McFarlane16-Jun-16 5:12
Kevin McFarlane16-Jun-16 5:12 
GeneralRe: Scala is the new golden child Pin
Rob Grainger16-Jun-16 9:22
Rob Grainger16-Jun-16 9:22 
AnswerRe: Scala is the new golden child Pin
Kevin McFarlane15-Jun-16 0:19
Kevin McFarlane15-Jun-16 0:19 
GeneralWhat about me...? Pin
Chris Maunder15-Jun-16 8:38
cofounderChris Maunder15-Jun-16 8:38 
GeneralRe: What about me...? Pin
Kevin McFarlane16-Jun-16 1:44
Kevin McFarlane16-Jun-16 1:44 
GeneralRe: What about me...? Pin
Rob Grainger19-Jun-16 22:25
Rob Grainger19-Jun-16 22:25 
GeneralRe: What about me...? Pin
Kevin McFarlane19-Jun-16 22:39
Kevin McFarlane19-Jun-16 22:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.