-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.hs
46 lines (38 loc) · 990 Bytes
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{-# LANGUAGE OverloadedStrings
, TemplateHaskell
, QuasiQuotes
#-}
module Main where
import Database.SQLite.Simple
import Database.SQLite.Simple.TypedQuery
import Data.String.QM
hello = $(genTypedQuery [qq|select (2 + 2) as sum -- Int |]) =<< open "test.db"
hello2 = $(genTypedQuery [qq|
select id -- Int
, str -- String
from test
|] ) =<< open "test.db"
ins = flip $(genTypedQuery [qq|
INSERT INTO
test ( str -- String
)
|] ) "test string 2" =<< open "test.db"
ins2 = $(genTypedQuery [qq|
INSERT INTO
test ( str -- String -- < "test string inlined"
)
|] ) =<< open "test.db"
ins3 = let
s = "test string scoped"
in $(genTypedQuery [qq|
INSERT INTO
test ( str -- String -- < s
)
|] ) =<< open "test.db"
main = do
ins
ins2
ins3
putStrLn "Me say hallo"
print =<< hello
print =<< hello2