If at some point of time something like haskell do notation or scala for
comprehension will be implemented in rust then it would be worth to look at
slick:
http://slick.typesafe.com/

Example from slick home page:

//--------------------------------------------------------
@table("COFFEES") case class Coffee(
  @column("COF_NAME")  name:  String,
  @column("SUP_ID") supID: Int,
  @column("PRICE") price: Double
)

val coffees = Queryable[Coffee]

val l = for {
  c <- coffees if c.supID == 101
} yield (c.name, c.price)

backend.result( l, session ).foreach { case (n, p) => println(n + ": " + p)
}
//--------------------------------------------------------

This approach quarantines real type safety (both in terms of dependency
injection and sql correctness)
and still give developers reasonable amount of space to tune details (code
is directly mapped to sql query, no ORM magic).


2013/12/11 Carter Schonwald <[email protected]>

> as another point in the design space, a pretty idiom for SQL style dbs in
> haskell is the *-simple family of libs
>
> postgres simple
>
> http://hackage.haskell.org/package/postgresql-simple-0.3.7.0/docs/Database-PostgreSQL-Simple.html
>
> mysql-simple
>
> http://hackage.haskell.org/package/mysql-simple-0.2.2.4/docs/Database-MySQL-Simple.html
> and
>
> sqlite-simple
>
> https://hackage.haskell.org/package/sqlite-simple-0.4.4.0/docs/Database-SQLite-Simple.html
>
> the common pattern is a nice way to write query strings and
> argument/result tuples in a type safe way, and are only really related in
> being a nice pattern for sql db interaction.
>
> note that by type safe, i mean injection safe! I think similar could be
> adapted to rust, perhaps with a wee bit of help using macros (which maybe
> aren't needed once higher kinded types/ traits) are around?
>
> On Wed, Dec 11, 2013 at 3:27 PM, spir <[email protected]> wrote:
>
>> On 12/11/2013 06:04 PM, Patrick Walton wrote:
>>
>>> We aren't likely to block 1.0 on this. Instead of stabilizing all
>>> libraries once
>>> and for all in 1.0 like Go did, we're taking a gradual approach to
>>> libraries
>>> similar to that of node.js, in which 1.0 will have some library modules
>>> stable
>>> and some modules unstable, and releases 1.1, 1.2, and beyond will
>>> stabilize more
>>> and more libraries as time goes on.
>>>
>>
>> A good thing, I guess, especially in that the latest trend in Rust seems
>> to be moving primitives into the library.
>>
>> Denis
>>
>> _______________________________________________
>> Rust-dev mailing list
>> [email protected]
>> https://mail.mozilla.org/listinfo/rust-dev
>>
>
>
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
>
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to