Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8454177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:57:24+00:00 2026-06-10T11:57:24+00:00

From Josh Suereth’s Scala in Depth: Applicative functors provide a way to take two

  • 0

From Josh Suereth’s “Scala in Depth”:

“Applicative functors provide a way to take two computations and join them together using a function. The Traversable example highlights how two collections can be parallelized into pairs. Applicative functors and parallel processing go together like bread and butter.”

I have a vague idea of the whole functors/monads/applicative stuff, but not exactly a strong grasp of it (new to the whole monad, functor stuff). I understand a bit of the concept of monads (flatten, flatMap) and monadic workflow, and functors (maps).

Can anyone please elaborate for me in terms of how it’s done, examples, and/or benefits of it versus “traditional” parallelization?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:57:26+00:00Added an answer on June 10, 2026 at 11:57 am

    I forwarded the question to Josh Suereth. This is his reply:

    Mike –

    I don’t have a lot of time to respond, but I’ll offer to examples of
    what I mean:

    Example #1 – Form Validation.

    I want to run some validation against input and aggregate all the
    errors, i.e. detect them in parallel. With applicative functions I
    can do so.

    So, given a set of “processing” functions, like so:

    def processUser(data: Data): Validation[User] = {
      if (data get "username" isEmpty) Failure("username must not be empty")
      else {  
         val Some(user) = data get "username"
         if (user contains badCharacterRegex) Failure(s"username must not contain one of ${badchars}")
         else Success(user)
      }
    }
    def processCreditCard(data: Data): Validation[CreditCard] = ...
    def processAddress(data: Data): Validation[Address] = ...
    
    def handleForm(data: Data): ??? = {
      (processUser(data), processCreditCard(data), processAddress(data)) map { (user, card, address) =>
        postPayment(user, address, card)
      } recover {   (errors) =>
         errors foreach println
      } 
    

    Now handle form will print out errors with CreditCard/username +
    address all at the same time, since you’ve combined them using an
    applicative functor. That’s parallel error reporting (although
    testing isn’t actually done in parallel).

    (2) Futures

    I want to do a few things in parallel and combine results. Future’s
    “zip” method is actually an applicative functor in disguise. I can do
    this:

    Future(computation1) zip Future(computation2) map { case (one,two) => .... }
    

    I’ve just used Applicative Functors to “join” parallel computations.
    It’s exactly the same as the Form validation example.

    Hope that helps!
    – Josh

    (note these code snippets are non-compilable examples; I was using SBT’s applicative syntax with the concepts in Scalaz, so you need to choose a library to use applicatives and what they are applying onto)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Chapter 2 of the new Manning book, Scala in Depth by Josh Sueresh is
After some great help from Josh Mein with a Javascript Hide/Show menu, the menu
From the Scala API , I got the following example, which does not compile;
While copying code for RelayCommand from Josh Smith article I copied following code public
I've got a lovely table function from josh.trow @ link that builds a 4x4
I'm attempting to implement the technique for data validation from Josh Smith's example here:
I have an application build with the MVVM pattern from Josh Smith ( http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
Consider the following from Effective Java Item 11 (Override clone judiciously) where Josh Bloch
I'm currently sending html formatted emails from PHP's mail() function and checking them simply
I lifted the following example from Josh Susser def strip_accents params thunk = lambda

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.