secret
Last active

  • Download Gist
NSObject+HSInit.m
Objective-C
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#import <Foundation/Foundation.h>
 
extern void hs_init (int *argc, char **argv[]);
extern void hs_exit (void);
 
@interface NSObject (HSInit)
@end
 
@implementation NSObject (HSInit)
+ (void)load {
hs_init(NULL, NULL);
atexit(&hs_exit);
}
@end

What would the matching Haskell code look like? I'm not familiar with FFI.

Nvm! I played with it and figured it out! Thanks for your work!

Just so others know - hs_init and hs_exit are already defined for you somewhere and they init and tear down the RTS, respectively.

This link helped me figure things out http://www.haskell.org/haskellwiki/Calling_Haskell_from_C.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.