selda 0.1.3.0 → 0.1.3.1
raw patch · 3 files changed
+23/−20 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +4/−0
- README.md +18/−19
- selda.cabal +1/−1
ChangeLog.md view
@@ -1,5 +1,9 @@ # Revision history for selda +## 0.1.3.1 -- 2017-05-01++* More hackage-friendly README.+ ## 0.1.3.0 -- 2017-04-30 * Add selectors for non-generic tables.
README.md view
@@ -1,7 +1,7 @@ Selda ===== [](https://travis-ci.org/valderman/selda)-<a href="https://www.irccloud.com/invite?channel=%23selda&hostname=irc.freenode.net&port=6697&ssl=1" target="_blank"><img src="https://img.shields.io/badge/IRC-%23selda-1e72ff.svg?style=flat" height="20"></a>+[](https://www.irccloud.com/invite?channel=%23selda&hostname=irc.freenode.net&port=6697&ssl=1)   @@ -38,7 +38,7 @@ $ cabal update $ cabal install selda selda-sqlite selda-postgresql -Then, read the [tutorial](#tutorial).+Then, read the tutorial. The [API documentation](http://hackage.haskell.org/package/selda) will probably also come in handy. @@ -52,7 +52,6 @@ installed (`libpq-dev` on Debian-based Linux distributions). -<span id="tutorial"></span> A brief tutorial ================ @@ -84,9 +83,9 @@ Running queries --------------- -Selda queries are run in the `SeldaT` monad transformer. Any `MonadIO` can be-extended with database capabilities. Throughout this tutorial, we will simply-use `SeldaT` on top of the plain `IO` monad.+Selda operations are run in the `SeldaT` monad transformer, which can be layered+on top of any `MonadIO`. Throughout this tutorial, we will simply use the Selda+monad `SeldaM`, which is just a synonym for `SeldaT IO`. `SeldaT` is entered using a backend-specific `withX` function. For instance, the SQLite backend uses the `withSQLite` function: @@ -96,7 +95,7 @@ people <- getAllPeople liftIO (print people) -getAllPeople :: SeldaT IO [Text :*: Int :*: Maybe Text]+getAllPeople :: SeldaM [Text :*: Int :*: Maybe Text] getAllPeople = query (select people) ``` @@ -139,12 +138,12 @@ database backend, as well as delete it. ```-setup :: SeldaT IO ()+setup :: SeldaM () setup = do createTable people createTable addresses -teardown :: SeldaT IO ()+teardown :: SeldaM () teardown = do tryDropTable people tryDropTable addresses@@ -163,7 +162,7 @@ Optional values are encoded as `Maybe` values. ```-populate :: SeldaT IO ()+populate :: SeldaM () populate = do insert_ people [ "Link" :*: 125 :*: Just "horse"@@ -193,7 +192,7 @@ :*: required "age" :*: optional "pet" -populate' :: SeldaT IO ()+populate' :: SeldaM () populate' = do insert_ people' [ def :*: "Link" :*: 125 :*: Just "horse"@@ -232,7 +231,7 @@ are updated. ```-age10Years :: SeldaT IO ()+age10Years :: SeldaM () age10Years = do update_ people (\(name :*: _ :*: _) -> name ./= "Link") (\(name :*: age :*: pet) -> name :*: age + 10 :*: pet)@@ -254,7 +253,7 @@ The following example deletes all minors from the `people` table: ```-byeMinors :: SeldaT IO ()+byeMinors :: SeldaM () byeMinors = deleteFrom_ people (\(_ :*: age :*: _) -> age .< 20) ``` @@ -278,7 +277,7 @@ restrict (age .> 20) return name -printGrownups :: SeldaT IO ()+printGrownups :: SeldaM () printGrownups = do names <- query grownups liftIO (print names)@@ -310,7 +309,7 @@ restrict (p ! age .> 20) return (p ! name) -printGrownups :: SeldaT IO ()+printGrownups :: SeldaM () printGrownups = do names <- query grownups liftIO (print names)@@ -380,7 +379,7 @@ restrict (home .== text city .&& name .== name') return name -printGrownupsInTokyo :: SeldaT IO ()+printGrownupsInTokyo :: SeldaM () printGrownupsInTokyo = do names <- query (grownupsIn "Tokyo") liftIO (print names)@@ -507,7 +506,7 @@ enjoys. Using transactions in Selda is super easy: ```-transferMoney :: Text -> Text -> Double -> SeldaT IO ()+transferMoney :: Text -> Text -> Double -> SeldaM () transferMoney from to amount = do transaction $ do update_ accounts (\(owner :*: _) -> owner .== text from)@@ -602,7 +601,7 @@ predecessors. Creating the tables is similarly easy: ```-create :: SeldaT IO ()+create :: SeldaM () create = do createTable (gen people) createTable (gen addresses)@@ -626,7 +625,7 @@ from the results of a query using the `fromRel` function. ```-getPeopleOfAge :: Int -> SeldaT IO [Person]+getPeopleOfAge :: Int -> SeldaM [Person] getPeopleOfAge yrs = do ps <- query $ do (name :*: age :*: _) <- select (gen people)
selda.cabal view
@@ -1,5 +1,5 @@ name: selda-version: 0.1.3.0+version: 0.1.3.1 synopsis: Type-safe, high-level EDSL for interacting with relational databases. description: This package provides an EDSL for writing portable, type-safe, high-level database code. Its feature set includes querying and modifying databases,