Created
July 15, 2012 01:15
-
-
Save jspahrsummers/3114225 to your computer and use it in GitHub Desktop.
Hypothetical messaging primitive for Objective-Haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mutableStringWithString :: Id -> IO Id | |
mutableStringWithString str = | |
getClass "NSMutableString" <.> stringWithString str | |
arrayWithObjects :: [Id] -> IO Id | |
arrayWithObjects objs = do | |
getClass "NSArray" <.> arrayWithObjectsAndCount objs (length objs) |
So, this works for the example you gave, and for any Id -> …
function, but it doesn't seem to work for IO Id -> …
:
mutableStringWithString :: Id -> IO Id
mutableStringWithString str = (getClass "NSMutableString") @. stringWithString str
Is there some way to make an <@.>
operator for lifting + applying + joining?
Yep! But you don't need to make a new operator. It's called (>>=)
. ;-)
mutableStringWithString str =
getClass "NSMutableString" >>= stringWithString str
That appears to drop str
into the self
position of stringWithString
, though.
Nope. Remember, we're putting the receiver last.
You're right. Sorry, I've been hopping back and forth between a few different mental models today.
;) no worries
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hmm, interesting. I'll make sure to add that. Thanks!