Skip to content
This repository was archived by the owner on Dec 5, 2019. It is now read-only.
This repository was archived by the owner on Dec 5, 2019. It is now read-only.

OHModel fields not always showing up correctly in ObjC (in PhotoUploader demo) #31

Open
@mrotondo

Description

@mrotondo

I was able to run the PhotoUploader demo, but found that the ObjC accessors behave very strangely. They'll successfully retrieve some of the fields from the Haskell record stored in the StablePtr, but not all. I added some logging in a couple places, and this is what happens when I run it:

JSONUtils.hs : decodeModel : putStrLn $ show json
(Successfully pulled down all data from Instagram)
:
Chunk "{\"meta\":{\"code\":200},\"data\":{\"username\":\"mrotondo\",\"bio\":\"Let's go alright!\",\"website\":\"http:\\/\\/rototyping.com\",\"profile_picture\":\"http:\\/\\/images.instagram.com\\/profiles\\/profile_3830567_75sq_1325740392.jpg\",\"full_name\":\"Roto\",\"counts\":{\"media\":42,\"followed_by\":62,\"follows\":36},\"id\":\"3830567\"}}" Empty

JSONUtils.hs : decodeModel : putStrLn $ show ((fromJust mv))
(Successfully parsed JSON into a User record)
:
User {userId = 3830567, username = "mrotondo", fullName = "Roto", bio = "Let's go alright!", photoURL = "http://images.instagram.com/profiles/profile_3830567_75sq_1325740392.jpg"}

UserViewModel.m : initWithAccessToken: : NSLog(@"User: %@", self.user);
(Only successfully accessed one field of Haskell record)
:
2012-08-11 05:37:10.900 PhotoUploader[4436:303] User: <User: 0x10161a2c0>{
    fullName = Roto;
    photoURL = "<null>";
    username = "<null>";
}

Model.hs : generated setter : putStrLn $ show user (after calling upd, and getting the user out of the MaybePtr)
(Successfully applied changes to record)
:
User {userId = 3830567, username = "mrotondo", fullName = "Kal-El", bio = "Let's go alright!", photoURL = "http://images.instagram.com/profiles/profile_3830567_75sq_1325740392.jpg"}

UserViewModel.m : initWithAccessToken: : NSLog(@"User post-update: %@", self.user); (after setting self.user to the new value)
(Still only successfully accessed one field of Haskell record)
:
2012-08-11 05:37:10.901 PhotoUploader[4436:303] User post-update: <User: 0x102a6ac60>{
    fullName = "Kal-El";
    photoURL = "<null>";
    username = "<null>";
}

Sometimes when I run it, it's able to access more fields, such as fullName and username, but it never gets all 3. I added a test case which basically does the exact same thing, generating a User object in Haskell (with fixed field values), exporting accessors, and asserting that the correct values are present, and it works great there, of course :).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions