Type-safe query layer for Persistent
Short description: Most real world applications need a persistence strategy that includes a database. Haskell needs a compelling solution for this. Currently the benefits of Haskell are offset by the lack of productivity for database interactions. The goal of this project is to turn the situation around: to make Haskell one of the best languages available for database interaction. The idea is to create a new query layer to be used on top of existing Persistent database serialization library. The new layer includes two domain specific languages: one for writing raw-SQL queries and another for writing MongoDB queries. Queries will be properly serialized and validated at compile-time.
Additional info: http://hackage.haskell.org/trac/summer-of-code/...
Type-safe query layer for Persistent
Most real world applications need a persistence strategy that includes a database. Haskell needs a compelling solution for this. Currently the benefits of Haskell are offset by the lack of productivity for database interactions. The goal of this project is to turn the situation around: to make Haskell one of the best languages available for database interaction.
The idea is to create a new query layer to be used on top of existing Persistent database serialization library. The new layer includes two domain specific languages: one for writing raw-SQL queries and another for writing MongoDB queries. All queries will be properly serialized and validated at compile-time.
This project is already standing on the shoulders of years of the community's work creating performant drivers and serialization infrastructure: it is just providing the missing layer on top of it.
We will implement a raw interface for MongoDB first because it is easier than SQL. Raw queries will still compose and there are no joins in the query language.
Schedule for the GSoC:
· Type-safe, raw MongoDB interface
o Document MongoDB query language as a Haskell data type
o Use quasi-quoter from mt-mongodb to convert mongodb-json query structure to Haskell data type
o Implement a converter from the data type to a query for the driver
o Polish and release
· Type-safe, raw SQL interface
o Combine different techniques into one unified and polished interface for raw SQL: hssqlppp for SQL validation. RawSql for handling joins, selecting single columns, returning Persistent Entities. persistent-hssqlppp to understand values like sum(column) and count(column) to know what type is going to be returned. getRawSql quasi-quoter to insert Haskell values into SQL more intuitively rather than using (?).
· Research a solution for record projections
· If a proper solution is found:
o Extend interfaces to support compile-time type resolving for a projection returned by a given query
o Provide a report to GHC users with given use case so that future improvements to Haskell records will take it into account
o Make general improvements of Persistent library. These include:
o Merge CouchDB backend (more information here)
o Examine using a more flexible Key type
o Examine integration with HaskellDB
Project progress shall be actively documented in a blog and code updated frequently on a branch in the Persistent Github repository. Persistent library test suite shall be extended with query tests and benchmarking. Documentation for new query layer will be added to Persistent section of the Yesod book and announcement shall be made in a Yesod blog to assure community is aware of the new features.
About the Student
I have been learning Haskell on my own for the past six months. I have experimented with Haskell a lot and created several things:
· IRC bot capable of reading and responding to user input in channel:
o !fml -> Random message from fmylife.com
o !weather <city> -> Weather information from google api
o !exchange <code1> <amount> <code2> -> Currency exchange using google api
o Source code can be found at https://github.com/kostas1/JellyBot
· Yesod based blog site:
o Two content types
§ Page, accessible through unique alias (generated from title)
§ Post – accessible by PostId with a Posts page where posts are listed and sorted by date
o Comments with reCAPTCHA for posts
o Haskell syntax highlighting with SHJS library
o Menu widget which follows currently opened page and adds css class .active accordingly
o Authentication and authorization to CRUD pages
o Source code can be found here
Besides Haskell experience I am working a lot in two other platforms:
Making applications with location-based services and rich UI. Involves heavy usage of Java/XML/SQL. My applications can be reached here. Four apps (all except FIDY Spillet) are made by me. There is also my personal application which I have done in an evening without having too much things to do and is found here.
Being one of the developers of web-based student admission system for my university. Usage of C#/XML/SQL. Unfortunately the system is not complete yet and is not accessible for public so I cannot provide a link to it.
From these two platforms I have gathered some relevant experience which can be used for given GSoC project. I have implemented different data access layers (some using DataMapper or Active Record pattern) both in Java and C#, worked a lot with platform-specific ORM libraries (Entity Framework on .NET, OrmLite on Android) and different data manipulations using SQL.
Some advanced SQL techniques include views, stored procedures and parameterized queries for protection against SQL injections. I am familiar with MSSQL/MySQL/SQLite databases and am able to setup them both on Windows and Linux (except MSSQL here)
During the project I will definitely need some help from wider audience. I plan to get main support from #Haskell channel when information on online books and articles is not available. Project will be mentored by Michael Snoyman and Greg Weber. Blake Rain, author of mt-mongo will mentor on re-use of that library. Felipe Lessa, author of Persistent's RawSql will mentor for that portion of the project.
I believe I am the right person for this project because I have all the relevant experience, motivation to work on it and desire to learn new things. I am really looking forward to participate in Haskell and Yesod communities and contribute to the projects to show my personal appreciation for the amazing software they have created.