KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I often find myself wanting to insert regular functions into a "binded" sequence. Like in this contrived example: getLine >>= lift (map toUpper) >>= putStrLn I need to define the lift function lift :: (a -> b) -> a -> m b to make this work. Problem is I don't know of such a function, and Hoogle doesn't seem to either. I find this odd since this makes totally sense to me. Now, there are probably other ways to make this work, but I like the way point-free style code allows me to scan the line in one pass to figure out what is happening. let lift f x = return (f x) in getLine >>= lift (map toUpper) >>= putStrLn My question boils down to this: am I missing something or how come there isn't a function like lift. My experience in Haskell is still very limited, so I am assuming that most people solve this in a different way. Can someone explain to me the idiomatic way of solving this.
Tags (comma-separated)
Save Edits
Cancel