22 | %language ElabReflection
25 | %hide Data.List.Alternating.infixl.(+>)
26 | %hide Data.List.Alternating.infixr.(<+)
27 | %hide Data.String.Extra.infixr.(<+)
28 | %hide Data.String.Extra.infixl.(+>)
29 | %hide JSON.ToJSON.infixr.(.=)
30 | %hide Prelude.Ops.infixl.(|>)
32 | ----------------------------------------------------------------------------------
33 | -- SQL --
34 | ----------------------------------------------------------------------------------
36 | -- A valid query is one with a type that has the appropriate instances
37 | -- for row conversions
46 | -- We can run any valid query and obtain the list of rows for that query
47 | export
52 | ----------------------------------------------------------------------------------
53 | -- APIs --
54 | ----------------------------------------------------------------------------------
56 | -- The errors that our program will deal with
61 | -- The monad in which we run our program as an endofunctor in Cont
66 | -- Interface for database commands. Commands only perform side-effects so the
67 | -- results are always Unit
72 | -- Interface of a database queries. Queries always return tables of a matching type
77 | ---------------------------------
78 | -- Running database operations --
79 | ---------------------------------
81 | -- Running a command as a costate
82 | export
86 | -- Running a query as a costate
87 | export
95 | -- Running either a command or a query on a database as a costate
96 | export
101 | export
104 | execSeqDB (More (MkEx (<+ x) cont)) = cmd {t = x.π1} x.π2 >> map (StarM ()) (execSeqDB (cont ()))
105 | execSeqDB (More (MkEx (+> x) cont)) = runValid x >>= \tbl => map (StarM tbl) (execSeqDB (cont tbl))
107 | ||| Run any amount of DB queries wrapped in SQL errors
108 | export