1

I have looked into "lifting" q/a's, examples it seemed to me lift function is just like any transformation function that changes the shape (like monad transformation).

Am I missing any point or lift function("lifting concept") does have any rules ?

If not is it just concept in functional transformations?

altayseyhan
  • 735
  • 1
  • 7
  • 18
  • Can you make one or more specific examples of lifting something somewhere? What kind of transformation are you talking about? I'm having trouble following. – Bergi Jul 10 '17 at 21:25
  • e.g https://stackoverflow.com/questions/17965059/what-is-lifting-in-scala val pf: PartialFunction[Int, Boolean] = { case i if i > 0 => i % 2 == 0} then calling pf.lift – altayseyhan Jul 10 '17 at 21:26
  • or in examples like here https://en.wikibooks.org/wiki/Haskell/Monad_transformers#Lifting – altayseyhan Jul 10 '17 at 21:32
  • 3
    The rules for "lifting" depend on what "lifting" means. If lifting means `liftM` then the rules are the `Functor` laws because `liftM` is another name for `fmap`. – Rein Henrichs Jul 10 '17 at 22:33
  • 5
    I think you're trying to generalize something that isn't generalizable. The Scala example lifts a function into a larger domain. The Haskell example is a monad transformer lift. There's also `liftM` which lifts a function into a functor scope. Each of these on their own follows rules, but the naming is just a coincidence. Like how object-oriented programmers and functional programmers mean totally different things when they talk about "composition". – Silvio Mayolo Jul 10 '17 at 22:40
  • 3
    Sadly `lift` is one of those words which means whatever the speaker wants it to mean (`hoist`'s another one), though it usually has some connotation of using something in a larger context. – Benjamin Hodgson Jul 11 '17 at 00:23
  • "lifting" typically refers to an [injection](https://en.wikipedia.org/wiki/Injective_function). The simplest examples (I can think of) of injections are `Left :: a -> Either a b`, `Right :: b -> Either a b`, and `Identity :: a -> Identity` (a trivial one). `lift` (from `MonadTrans`), `liftM`, and the scala examples in the linked question are all injections. (Aside: all the claims here that "lift means whatever you want it to mean" are silly. Clearly a word means whatever you chose! But clearly there is a commonly understood underlying concept) – user2407038 Jul 11 '17 at 13:42
  • @user2407038, usually, but not always. `data U2 m a = U2` `instance MonadTrans U2 where lift _ = U2` defines a perfectly valid `MonadTrans` instance, but not an injection. The same goes for `liftM`/`fmap` to a trivial functor. Injectivity is also certainly insufficient for most senses of "lift". So I don't think injectivity really has anything to do with it. – dfeuer Jul 15 '17 at 20:41

1 Answers1

-1

Lifting doesn't change the 'shape', just the 'type'. By this I mean that lifting a function into, e.g., a List<A> results in a List<B>. The shape (List) doesn't change, but the specific type may.

You are right that it is similar to any other transformation. In fact, the standard operation map is the mechanism of 'lifting' a function of a single variable into the Functor (the datatype being mapped over). So, you can think of map as lift1, then you have lift2 (for functions of two variables), etc.

melston
  • 2,198
  • 22
  • 39