March 7, 2010

GravatarMichael Snoyman

Now that the first version of Yesod Web Framework has been released, I can start to think about the missing piece of the puzzle: the model. Currently, each of my sites built on Yesod uses a hand-rolled model layer. In SearchOnce, this was particularly ugly: a 900 line file with a bunch of SQL code.

So I've been playing around with some ideas, and I just want to get them out for later reference. There's no code to back this one up yet, so don't expect anything concrete for a while!

  • Using YAML and quasi-quotation worked very nicely for URL dispatch in Yesod; I think that will be a good fit for defining models.
  • Overall, Django model system is pretty good, probably follow that structure mostly.
  • There's no reason to tie it down to SQL; I can imagine a YAML-file backend, or Amazon SimpleDB. At the same time, SQL should be a first-class citizen.
  • Not sure if it should have schema-generation, you tell it the names of your tables, or an option for either one.
  • IO thunks would probably be a good idea for possibly expensive records (eg, in a one-to-many relationship).
  • Speaking of relationships, is one-to-many and many-to-many sufficient? And how do you model many-to-many in Haskell?
  • Probably want to use data-accessor or something similar.
  • Maybe consider an IOList (or Stream) data structure: data IOList a = IONil | IOCons a (IO IOList).
  • Have to figure out a way to interoperate with HStringTemplate, which might ultimately involve unsafePerformIO due to the purity of that library.
  • Does data-object need to include a MonadObject data structure to help this out?

Sorry for just spouting nonsense for now... if anyone has any ideas or recommendations of already-existent libraries, please let me know.


comments powered by Disqus