Hello again! :)
@Jeff: Yeah, I do realize this project can be quite hard. I have a
full semester to finish it. I am doing it as a course project. Looking
at Http API helped a little bit! But not much! Please read on :)
@John Thanks! I have tried to finish reading the Wormholes paper, I
keep having to stop reading to understand things having to do with
type classes, resource types, lack of any experience with Haskell is
not helping at all. From what I could understand, I really like the
idea of Wormholes and would like to implement an analogue if possible,
see my API and let me know your thoughts!
@Max: see my question about mutate function below!
I have been working on compiling Elm to Meteor, right now I have a
crude hack that works for toy projects. Using Meteor, I have created a
simplistic Database API, check it out here:
https://github.com/shashi/Elm/blob/elm-on-meteor/libraries/Database.elm
I made a simple example (Stamps, but multi-user)
http://stamptogether.meteor.com/
The code for the app:
https://github.com/shashi/Elm/blob/elm-on-meteor/stamp/main.elm (It's
29 lines!!!)
I would really love comments on the API!
Consider this alternative implementation of mutate:
mutate : Collection a -> Signal (Mutation a) -> Signal (Response a)
I really liked this at first. But there are issues with this. If
mutate were a function which takes a signal of mutations and returns a
signal of asynchronous responses (responses may not be in the same
order as the mutations), it would be pretty useless (because how are
you going to use it to do error handling?)! This is similar to
Http.send, but not quite. In Http.send you only care about the most
latest request (for example, as in Flickr example). But in my case
what I want is an acknowledgement for every mutation. But these may
not be received in the same order as the Mutation. The way JavaScript
in Database.Native deals with this right now is it just returns what
the non-blocking call to Meteor.Collection.update, but the right way
to do this is to pass an callback argument. See
http://docs.meteor.com/#update
I think I like imagining my data sources as a source from which
Database-dependent signals can be set up (using select) and a sink to
which mutations can be thrown (using mutate).
Evan likes DataLog type API, which makes a lot of sense in a
functional programming context. I have a few ideas on how to do this,
but meteor for now provides only MongoDB interaction, which should in
theory allow me to do something like DataLog, but I don't want to do
it if it's going to be tied down to MongoDB. Some sort of a thin layer
which can use any database as a backend would be cool. Will write my
ideas to the group soon.
Lastly, I am looking to allow programs to separate out client code and
server code. In Meteor, anything within an if (Meteor.isServer) {} is
private to the server. Meteor.isServer is the substrate with which
this will need to be implemented, but what is the best way to expose
the means of this separation in the language? You cannot do the same
in Elm since this is quintessentially stateful. You can probably allow
some way to annotate functions and modules as server-bound. What about
having a serverMain variable that is similar to main but runs inside a
Meteor.isServer? Although I have used Meteor on a few toy projects, I
haven't had to write a lot of server-bound code in them.
I have been wanting to write this for a long time, but kept wanting to
improve the API, but since recently there has been some interest in
doing this sort of thing, I decided to just put out what I have.
Thanks a lot!
Regards
Shashi