Created
March 2, 2015 22:32
-
-
Save ThomasCrevoisier/af1a47fc2628a262d600 to your computer and use it in GitHub Desktop.
Foreign Import
This file contains hidden or 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
| {- Non-working version -} | |
| foreign import mapHRecLabel | |
| "function mapHRecLabel(f, rec) {\ | |
| \ var mapped = {};\ | |
| \ for (var k in rec) {\ | |
| \ if (rec.hasOwnProperty(k)) {\ | |
| \ mapped[k] = f(k, rec[k]);\ | |
| \ }\ | |
| \ }\ | |
| \ return mapped;\ | |
| \}" :: forall a b. Fn2 (String -> a -> b) (HRec a) (HRec b) | |
| {- Working version -} | |
| foreign import mapHRecLabel | |
| "function mapHRecLabel(f, rec) {\ | |
| \ var mapped = {};\ | |
| \ for (var k in rec) {\ | |
| \ if (rec.hasOwnProperty(k)) {\ | |
| \ mapped[k] = f(k)(rec[k]);\ | |
| \ }\ | |
| \ }\ | |
| \ return mapped;\ | |
| \}" :: forall a b. Fn2 (String -> a -> b) (HRec a) (HRec b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment