DEV Community

Discussion on: When is nesting good or neutral?

Collapse
 
jbristow profile image
Jon Bristow • Edited

And now with monads....

fun conditionalsOrNo(maybeCode: Either<Error, Code>) = maybeCode.map(Code::writeConditionals)

Please note that this example is bad because it appears to rely on side effects

Collapse
 
cishiv profile image
Shivan Moodley

I have googling to do it seems

Thread Thread
 
jbristow profile image
Jon Bristow

Please note that the brevity of my example relies upon a strong type system with at least basic generics support.

Interesting google terms:

Discriminated Unions
Functional programming
Monads
Haskell (or Hindley-Milner type systems)
Lodash (decent javascript functional library, though this may be a little opaque unless you experiment with a FP language for a while)

Thread Thread
 
cishiv profile image
Shivan Moodley

Thank you for this. I'll add it to this weekends reading list.