Starting from scratch
I based my project on pulp which is used in this example here, which was again created by Bodil. This is a good starting point and a lot simpler than the grunt build I was using to initially learn PureScript.
Code and Types and Data oh my
Here is the code for the working application.
Take note the extra empty string argument used in the easy-ffi methods. According to the docs this is needed if the method returns an action. When using unsafeForeignFunction of easy-ffi, pass an empty string argument in the argument array so it executes correctly. Like this.
map' = ffi ["s", ""] "L.map(s)"
This threw me for a loop for a while, but when I rewrote these functions without easy-ffi it kind of makes sense… I think. The above function would probably look like this.
These functions are curried and there is a function wrapped around the L.map(s) method, so I think that’s what the empty argument is for, to call that method. At least to my eyes that’s what it looks like. I could be totally wrong though. Please tell me so I can update this post later.
This demo application is available here.
What the hell
I’m still in my early learning phase with PureScript so far. I’m not even done with the PureScript by Example book yet. I got too excited. There is also a 24 Days of PureScript guide which has tons of great info.
I don’t know if I’ll have a chance to push PureScript into production (my team would kill me), but I am definitely a fan and will continue to play around with it.
Update – It turns out there is a purescript-leaflet library already on github that is working towards doing bindings for purescript. I’ll be giving this a shot next!