Is there a Haskell database using algebraic data types?

I program vocabulary in Haskell in my free time.

I have a file with words where elements are modeled as algebraic data types that 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 of _deu= and _satz= most often represents an empty string that I want to update as part of the program.

Now I have a few questions: 1. Is there a database that uses Haskell data types for haskell (I would really like my type to have type safety too)? What I found are HDBC bindings to MySQL and the like, as well as some other xml / JSON stuff.

  • If I update the file instead of using the database, is there a way to recompile the entire program - it would be a little tedious to do this.

and the third question

I want to save the studied dictionaries in a data structure that needs to be updated frequently, since at each stage of training I update a number indicating the knowledge of this word and sort this data structure when pasting / or after it. Then I select a new word based on its position in this data structure. Lists seem inefficient to do a full enumeration of the list, and sorting is a big effort if there is a better solution. Note, finally, I only have 5,000 entries in the list, so maybe this worries speed in the wrong place?

+10
database algebraic-data-types haskell
source share
2 answers

Essentially, take a look at Acid-State . There's also a tutorial for him as part of the Crash Hackstack course.

It does what you ask for in terms of maintaining type safety in the model. I'm not sure how useful this is for you, but I used it in several web applications, including here and here (the second part is part of an HDBC benchmarking attempt against MongoDB and AcidState, so you can use it to see how three compare implementation in the context of a Haskell web application).

To your third question, with 5,000 insertions / readings, you really shouldn't have to worry about performance. If you look at the benchmarks that I mentioned , the “big” benchmark carries out (relatively small) 50,000 transactions in a very short order and they were more fleshy inserts than what you seem to be doing.

+9
source share

Persistent from Yesod will open:

Persistent is Yesods' answer to data storage - a versatile data storage interface for Haskell, type safe.

[...]

Persistent allows us to choose between existing databases that are highly customizable for different cases of using a data warehouse, interact with other programming languages ​​and use a safe and productive query interface, while preserving the type of security of Haskell data types.

Permanent follows type safety guidelines and concise, declarative syntax.

+8
source share

All Articles