> > How do you define relationships between data types?
Well, why is it any different from other fields? From one of your examples [1], I'd expect you to have a list of questions in the Quiz data type, and if necessary, a quiz field in the Question data type. This might be a bit tricky but certainly achievable [2]. Something like the following: data Quiz = Quiz { description :: String, subject :: String, questions :: [Question] } deriving (Show, Read) data Question = Question { title :: String, choiceA :: String, choiceB :: String, choiceC :: String, quiz :: Quiz } deriving (Show, Read) [1] http://github.com/chriseidhof/persist/blob/master/examples/Model.phs [2] http://www.haskell.org/haskellwiki/Tying_the_Knot On 28 September 2010 16:13, Chris Eidhof <ch...@eidhof.nl> wrote: > Hey Jonathan, > > I've done some work on this. The hard part is defining relationships > between datatypes: how do you model this in Haskell? I've some code on > github: http://github.com/chriseidhof/persist, you might be interested in > that. > > -chris > > On 25 sep 2010, at 21:31, Jonathan Geddes wrote: > > > Cafe, > > > > HaskellDB takes a database schema and produces Haskell data structures > > (plus some other query-related stuff for its EDSL query language). > > > > What I'm looking for is the inverse of this functionality. I want to > > create tables based on a Haskell data structure with a few simple > > rules. These rules include: if a field is not of the form `Maybe a' > > then it can't be nullable in the database. If a field is not a > > primitive (in the database) then it is actually stored in another > > table and a reference id is stored in the table. Tables are produced > > recursively, unless they already exist, etc. > > > > The HaskellDB approach is great for interfacing with existing tables, > > but in my case I already have data structures and now I would like a > > quick way to create tables to persist them. > > > > Does such a thing exist? If not, would you find it useful? I may take > > this up as a side project if it does not already exist and others > > would find it useful. > > > > Thanks, > > > > --Jonathan > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Ozgur Akgun
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe