• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Functional Design and Architecture - Do you need monads?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Alexander,

I know that there are some difficulties that comes along learning monads, but I also know that they are useful and powerful. But is it required when building FP applications?
Do you need them for complex applications, and skip them for non-complex ones?

Thanks,
Richard
 
Rancher
Posts: 369
22
Mac OS X Monad Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Haskell, you really can't avoid monads -- any code with side effects is monadic in Haskell, for example, and monads are a commonly-used abstraction for a lot of other things too.

That said, monads aren't really as "scary" as you might think -- I pretty much guarantee you're already using monadic forms in your day-to-day programming without even knowing it. Using Optional<> in Java? Monads. Using a for-comprehension (present in several languages)? Monads. In Haskell, they are just more obvious and more formalized.
 
Author
Posts: 27
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Richard Rodriguez wrote:Hi Alexander,

I know that there are some difficulties that comes along learning monads, but I also know that they are useful and powerful. But is it required when building FP applications?
Do you need them for complex applications, and skip them for non-complex ones?

Thanks,
Richard



Hi Richard,

Thank you for the question!

Strictly speaking, you don't need monads in your FP applications, but you need a sequential IO. It's only Haskell who implements the sequential IO on top of the monads mechanism, and it's a very FPish solution. Other FP languages just let you doing sequential imperative calls.

What about non-IO monads, I'm sure that people implement this monadic behavior in different scenarios all the time, they are just unaware of this fact. What is ROP in F# if not a kind of Either monad? I'm sure Scott Wlaschin knows this, he just avoids calling it a monad.
 
reply
    Bookmark Topic Watch Topic
  • New Topic