Questions tagged [lifting]

a transformation of a function into a corresponding function in a more general context.

84 questions
3
votes
1 answer

Lift to fix the *inside* of a monad transformer stack

Suppose I have an IO Int wrapped in a StateT MyState, then I have a value of State MyState Int which I want to use in the stacked monad. How do I lift it in this inner sense? I already know to use lift or liftIO if I get something compatible with…
Adrian May
  • 2,127
  • 15
  • 24
3
votes
1 answer

Monad transformer – Explicit lifting

I'm reading about monad transformers in Real World Haskell. In the following example, the stack is Writer on top State on top of Reader on top of IO. {-# Language GeneralizedNewtypeDeriving #-} import Control.Monad import…
beta
  • 2,380
  • 21
  • 38
3
votes
4 answers

Is there a name for this kind of lifting a function?

I wrote a Scala function: def liftOrIdentity[T](f: (T, T) => T) = (a: Option[T], b: Option[T]) => (a, b) match { case (Some(a), None) => Some(a) case (None, Some(b)) => Some(b) case (Some(a), Some(b)) => Some(f(a, b)) …
Felix
  • 8,385
  • 10
  • 40
  • 59
3
votes
1 answer

Lift Kleisli arrow into IO?

If I have the following two Kleisli arrows: stdoutProcessA :: Kleisli Maybe String (IO String) writeToFileA :: Kleisli Maybe (FilePath, String) (IO ()) I would like to be able to write someting like: compile = proc src -> do output <-…
Philip Kamenarsky
  • 2,757
  • 2
  • 24
  • 30
3
votes
2 answers

why can't I use iterate to repeatedly apply map?

I've come to the realization that when I have nested data structures, I've been manually writing code to delve into them. Like this: --one level Prelude> map (*2) [1,2,3] [2,4,6] --nested two levels Prelude> let t2 = map $ map (*2) Prelude> t2…
nont
  • 9,322
  • 7
  • 62
  • 82
2
votes
0 answers

functional programming terminology: lifting vs functor/applicative lifting

I'm writing a functional programming library and I'm trying to decide which name is best for a series of functions. The functions all take a function and return another function. The returned function has a different return type compared to the…
Emmanuel Touzery
  • 9,008
  • 3
  • 65
  • 81
2
votes
1 answer

Lifting - generalization

I need to use heavy function lifting, eg. k = myFunc <$> someFunctionName 1 <*> someFunctionName 2 <*> someFunctionName 3 <*> someFunctionName 4 <*> someFunctionName 5 <*> someFunctionName 6 <*> someFunctionName 8 <*>…
radrow
  • 6,419
  • 4
  • 26
  • 53
2
votes
1 answer

react lifting state up after login verified

I'd like to create component - - so that only authorised users can access it. the idea is that after receiving response 200 from backend in my Login component (which is a child component) I would somehow use authed:true as props in parent…
Gregor Sotošek
  • 357
  • 1
  • 4
  • 22
2
votes
0 answers

How to lift a fold|map|both into the Either monad?

A "map" of type mapIsh :: Traversable t => (a -> Either b c) -> t a -> Either b (t c) would be a start. (Hayoo doesn't find one.) Or a "fold" of type foldIsh :: (b -> a -> Either l b) -> b -> t a -> Either l b Best of all (for my case) would be…
Jeffrey Benjamin Brown
  • 3,427
  • 2
  • 28
  • 40
2
votes
1 answer

Use of a monad superclass in a monad instance declaration?

I'm implementing a very simple poor mans concurrency structure with the following data type: data C m a = Atomic (m (C m a)) | Done a I'm creating an instance of monad for this: instance Monad m => Monad (C m) where (>>=) (Atomic m) f =…
Babra Cunningham
  • 2,949
  • 1
  • 23
  • 50
2
votes
1 answer

Equality in Agda - irrelevant arguments

I have a dependant type that consists of a value plus some proofs about its properties. Naturally I would like my notion of equality over this type to be equivalent to equality over the value component. This is all fine except that I run into…
user2667523
  • 190
  • 1
  • 9
2
votes
1 answer

Lifted „if“-function behaves unexpectedly

in my program I use a function if' defined in one of the modules instead of the built-in if-then-else construct. It is defined trivially and works just fine. However, there's one place in code where I need to apply it to monad values (IO in my…
Xyzzy1201
  • 23
  • 2
2
votes
1 answer

Lifting a function with another function as an argument in Haskell

So I have a function in Haskell that I've simplified for the purpose of asking this question: import Data.Foldable import Data.Set myFn :: Int -> Set Int myFn a | a <= 0 = singleton 1 | otherwise = foldMap helper (myFn (a - 1)) helper :: Int…
arussell84
  • 2,443
  • 17
  • 18
2
votes
3 answers

Scala strange implicit boxing conversion error

Can someone tell me why the following does not work? object TestObject { def map(f: (Double, Double) => Double, x2: Array[Double]) = { val y = x2.zip( x2 ) val z = y.map(f) z } } Produces this error: type mismatch;…
OutNSpace
  • 373
  • 2
  • 8
1
vote
1 answer

How can i Lifting x86_64 assembly code to LLVM-IR?

I'm researching of virus and I'm faced with the task of deobfuscating its virtual machine. I chose to do this through LLVM and I had a question, where can I see a simple example of lifting instructions to the LLVM-IR level? For example, where can I…
OSPFv3
  • 33
  • 5