Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Haskell database using algebraic datatypes? [closed]

I am programming a vocabulary trainer in Haskell in my spare time.

I have a file with the words where entries are modeled as algebraic data types, which look like

Word { _frq=1
     , _fra="le"  
     , _eng="the; him, her, it, them"
     , _deu="der,die,das; er,sie,es"
     , _uses=[Determiner [], Pronoun []]
     , _phrase=" vive la politique, vive l'amour"
     , _sentence="long live politics, long live love"
     , _satz="Lang lebe die Politik, lang lebe die Liebe."
     }

Most often the german translation _deu= and _satz= is most often just an empty string which I want to update within the program.

Now I have a few questions: 1. Is there a database using Haskell datatypes for haskell (I would really like type safety in my database too)? The things I found were the HDBC bindings to MySQL and the like, and some other xml/JSON stuff.

  1. If i update the file instead of using a database, is there a way around recompiling the whole program - it would be a bit tedious to do that.

and a third question

I want to save the learnt vocabularies in a datastructure which needs often to be updated, as in each learning step i update a number indicating the knowledge of this word - and sort this datastructure while inserting/or afterwards. Then i pick a new word based on its position in this datastructure. Lists seem to be inefficient for doing a full list traversal and sorting is a big effort if there is a better solution. A note at last I do have only 5000 list entries, so maybe is it worrying about speed in the wrong place?

like image 648
epsilonhalbe Avatar asked Aug 19 '13 13:08

epsilonhalbe


1 Answers

Database-wise, take a look at Acid-State. There's also a tutorial for it as part of the Happstack Crash Course.

It does what you ask in terms of maintaining type safety in the model. I'm not sure how useful this'll be for you, but I've put it to use in a couple of web-apps, including here, and here (that second one is part of a benchmarking attempt pitting HDBC against MongoDB and AcidState, so you can use it to see how the three compare implementation-wise in the context of a Haskell web-application).

To your third question, at 5000 inserts/reads, you really shouldn't be worried about performance. If you take a look at those benchmarks I mentioned, the "large" benchmark runs a (relatively small) 50 000 transactions in very short order, and they were meatier insertions than what you seem to be doing.

like image 102
Inaimathi Avatar answered Nov 15 '22 22:11

Inaimathi