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 6091427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:19:35+00:00 2026-05-23T12:19:35+00:00

In Learn You a Haskell for Great Good! author claims that Applicative IO instance

  • 0

In “Learn You a Haskell for Great Good!” author claims that Applicative IO instance is implemented like this:

instance Applicative IO where
    pure = return
    a <*> b = do
        f <- a
        x <- b
        return (f x)

I might be wrong, but it seems that both return, and do-specific constructs (some sugared binds (>>=) ) comes from Monad IO. Assuming that’s correct, my actual question is:

Why Applicative IO implementation depends on Monad IO functions/combinators?

Isn’t Applicative less powerfull concept than Monad?


Edit (some clarifications):

This implementation is against my intuition, because according to Typeclassopedia article it’s required for a given type to be Applicative before it can be made Monad (or it should be in theory).

  • 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-05-23T12:19:35+00:00Added an answer on May 23, 2026 at 12:19 pm

    (…) according to Typeclassopedia article it’s required for a given type to be Applicative before it can be made Monad (or it should be in theory).

    Yes, your parenthetical aside is exactly the issue here. In theory, any Monad should also be an Applicative, but this is not actually required, for historical reasons (i.e., because Monad has been around longer). This is not the only peculiarity of Monad, either.

    Consider the actual definitions of the relevant type classes, taken from the base package’s source on Hackage.

    Here’s Applicative:

    class Functor f => Applicative f where
        pure  :: a -> f a
        (<*>) :: f (a -> b) -> f a -> f b
        (*>)  :: f a -> f b -> f b
        (<*)  :: f a -> f b -> f a
    

    …about which we can observe the following:

    • The context is correct given currently existing type classes, i.e., it requires Functor.
    • It’s defined in terms of function application, rather than in (possibly more natural from a mathematical standpoint) terms of lifting tuples.
    • It includes technically superfluous operators equivalent to lifting constant functions.

    Meanwhile, here’s Monad:

    class Monad m where
        (>>=)       :: m a -> (a -> m b) -> m b
        (>>)        :: m a -> m b -> m b
        return      :: a -> m a
        fail        :: String -> m a
    

    …about which we can observe the following:

    • The context not only ignores Applicative, but also Functor, both of which are logically implied by Monad but not explicitly required.
    • It’s also defined in terms of function application, rather than the more mathematically natural definition using return and join.
    • It includes a technically superfluous operator equivalent to lifting a constant function.
    • It also includes fail which doesn’t really fit in at all.

    In general, the ways that the Monad type class differs from the mathematical concept it’s based on can be traced back through its history as an abstraction for programming. Some, like the function application bias it shares with Applicative, are a reflection of existing in a functional language; others, like fail or the lack of an appropriate class context, are historical accidents more than anything else.

    What it all comes down to is that having an instance of Monad implies an instance for Applicative, which in turn implies an instance for Functor. A class context merely formalizes this explicitly; it remains true regardless. As it stands, given a Monad instance, both Functor and Applicative can be defined in a completely generic way. Applicative is “less powerful” than Monad in exactly the same sense that it is more general: Any Monad is automatically Applicative if you copy+paste the generalized instance, but there exist Applicative instances which cannot be defined as a Monad.

    A class context, like Functor f => Applicative f says two things: That the latter implies the former, and that a definition must exist to fulfill that implication. In many cases, defining the latter implicitly defines the former anyway, but the compiler cannot deduce that in general, and thus requires both instances to be written out explicitly. The same thing can be observed with Eq and Ord–the latter obviously implies the former, but you still need to define an Eq instance in order to define one for Ord.

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

Sidebar

Related Questions

I'm trying to compile this function from Learn You a Haskell for Great Good
Learn You a Haskell mentions difference lists (search for this term on that page),
I am trying to learn pure functional programming language like Haskell as I am
I was reading a Haskell tutorial (Learn You a Haskell) in which the author
I've been doing my annual attempt to learn Haskell this weekend, and as ever
I'm going through the 'Learn you a Haskell' tutorial and I am at this
I am learning Haskell and reading the book, Learn You a Haskell for Great
I'm starting to learn Haskell by doing the 99 Haskell problems. http://www.haskell.org/haskellwiki/H-99:_Ninety-Nine_Haskell_Problems I'd like
I just have started to learn Haskell and combine reading books and tutorials with
I am new to functional programming, and now learn Haskell. As an exercise I

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.