[Ur] Need help with desugaring dml

fold at tuta.io fold at tuta.io
Sat Feb 11 04:09:50 EST 2017


Sergey,
Something similar to this:https://github.com/achlipala/upo/blob/master/sql.ur#L44
and this:https://github.com/achlipala/upo/blob/master/sql.ur#L50might help you a bit.
Also check other functions in sql.ur
I believe you also can figure out desugared type expressions from compiler error output if you replace parts of your code with simple expressions of known type.
https://wiki.haskell.org/GHC/Typed_holes





11. Feb 2017 21:18 by grrwlf at gmail.com:


> Hi. I'm trying (again) to write an Ur/Web module to provide API for
> managing OS-level processes. I expect users to pass it a table
> containing _at_least_ id, process command name, arguments, placeholder
> for exit code and status string. It is expected that users will use
> tables containing more problem-specific columns.
>
> The problem is that I cant use simple dml operations anymore. As a
> start, I tried to write dummy insert using [demo/more/orm.ur] as
> example, but was stopped by difficult [ensql] function. Could you
> please help me to implement it?  The code is quite short and listed
> below.
>
> Regards,
> Sergey
>
> ---
>
> con jobinfo = [
>     Id = int
>   , ExitCode = option int
>   , Cmd = string
>   , Hint = string
>   ]
>
> functor Make(M : sig
>
>   con u
>
>   constraint [Id,ExitCode,Cmd,Hint] ~ u
>
>   table t : (jobinfo ++ u)
>
>   sequence s
>
> end) = struct
>
>   open CallbackFFI
>
>   type row' = record (jobinfo ++ M.u)
>
>   (* fun ensql [avail ::_] (r : row') : $(map (sql_exp avail [] []) fs') = *)
>   (*     @map2 [meta] [fst] [fn ts :: (Type * Type) => sql_exp avail
> [] [] ts.1] *)
>   (*      (fn [ts] meta v => @sql_inject meta.Inj v) *)
>   (*      M.folder M.cols r *)
>
>   (* createSync will start the job, but in this example it just does a
> simple insert.
>     args is a problem-specific part of the table record.
>
>     How to make this dml(insert..) work? *)
>
>   fun createSync (ji : record jobinfo, args : record M.u) :
> transaction (option int) =
>     i <- nextval M.s;
>     dml(insert M.t ({Id = sql_inject ji.Id,
>           ExitCode = sql_inject ji.ExitCode,
>           Cmd = sql_inject ji.Cmd,
>           Hint = sql_inject ji.Hint} ++ (ensql args) ));
>
>     return (Some i)
>
> end
>
> _______________________________________________
> Ur mailing list
> Ur at impredicative.com
> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20170211/61a3c42e/attachment.html>


More information about the Ur mailing list