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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:54:17+00:00 2026-05-13T22:54:17+00:00

I don’t understand what lifting is. Should I first understand monads before understanding what

  • 0

I don’t understand what “lifting” is. Should I first understand monads before understanding what a “lift” is? (I’m completely ignorant about monads, too 🙂 Or can someone explain it to me with simple words?

  • 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-13T22:54:18+00:00Added an answer on May 13, 2026 at 10:54 pm

    Lifting is more of a design pattern than a mathematical concept (although I expect someone around here will now refute me by showing how lifts are a category or something).

    Typically you have some data type with a parameter. Something like

    data Foo a = Foo { ...stuff here ...}
    

    Suppose you find that a lot of uses of Foo take numeric types (Int, Double etc) and you keep having to write code that unwraps these numbers, adds or multiplies them, and then wraps them back up. You can short-circuit this by writing the unwrap-and-wrap code once. This function is traditionally called a "lift" because it looks like this:

    liftFoo2 :: (a -> b -> c) -> Foo a -> Foo b -> Foo c
    

    In other words you have a function which takes a two-argument function (such as the (+) operator) and turns it into the equivalent function for Foos.

    So now you can write

    addFoo = liftFoo2 (+)
    

    Edit: more information

    You can of course have liftFoo3, liftFoo4 and so on. However this is often not necessary.

    Start with the observation

    liftFoo1 :: (a -> b) -> Foo a -> Foo b
    

    But that is exactly the same as fmap. So rather than liftFoo1 you would write

    instance Functor Foo where
       fmap f foo = ...
    

    If you really want complete regularity you can then say

    liftFoo1 = fmap
    

    If you can make Foo into a functor, perhaps you can make it an applicative functor. In fact, if you can write liftFoo2 then the applicative instance looks like this:

    import Control.Applicative
    
    instance Applicative Foo where
       pure x = Foo $ ...   -- Wrap 'x' inside a Foo.
       (<*>) = liftFoo2 ($)
    

    The (<*>) operator for Foo has the type

    (<*>) :: Foo (a -> b) -> Foo a -> Foo b
    

    It applies the wrapped function to the wrapped value. So if you can implement liftFoo2 then you can write this in terms of it. Or you can implement it directly and not bother with liftFoo2, because the Control.Applicative module includes

    liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c
    

    and likewise there are liftA and liftA3. But you don’t actually use them very often because there is another operator

    (<$>) = fmap
    

    This lets you write:

    result = myFunction <$> arg1 <*> arg2 <*> arg3 <*> arg4
    

    The term myFunction <$> arg1 returns a new function wrapped in Foo:

    ghci> :type myFunction
    a -> b -> c -> d
    
    ghci> :type myFunction <$> Foo 3
    Foo (b -> c -> d)
    

    This in turn can be applied to the next argument using (<*>), and so on. So now instead of having a lift function for every arity, you just have a daisy chain of applicatives, like this:

    ghci> :type myFunction <$> Foo 3 <*> Foo 4
    Foo (c -> d)
    
    ghci: :type myFunction <$> Foo 3 <*> Foo 4 <*> Foo 5
    Foo d
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't understand where the extra bits are coming from in this article about
Don't know a whole lot about streams. Why does the first version work using
Don't really know how to formulate the title, but it should be pretty obvious
Don't know if this has been asked before, so point me to another question
Don't think that I'm mad, I understand how php works! That being said. I
Don't know if anyone can help me with this or if it's even possible.
Don't have much to say, just can get into the event handler. XAML: <Grid>
Don't shoot me, but it's the first time I saw a usage of a
Don't be to hard on me, this is my first try with JSF. I
Don't these two mean the same thing, first get the value and then increment?

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.