<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
Sergey,<div><br /></div><div>Something similar to this:</div><div><a href="https://github.com/achlipala/upo/blob/master/sql.ur#L44" target="_blank" rel="noopener noreferrer">https://github.com/achlipala/upo/blob/master/sql.ur#L44</a><br />and this:</div><div><a href="https://github.com/achlipala/upo/blob/master/sql.ur#L50" target="_blank" rel="noopener noreferrer">https://github.com/achlipala/upo/blob/master/sql.ur#L50</a></div><div>might help you a bit.</div><div><br /></div><div>Also check other functions in sql.ur</div><div><br /></div><div>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.</div><div><br /></div><div><a href="https://wiki.haskell.org/GHC/Typed_holes" target="_blank" rel="noopener noreferrer">https://wiki.haskell.org/GHC/Typed_holes</a><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br />11. Feb 2017 21:18 by <a href="mailto:grrwlf@gmail.com" target="_blank" rel="noopener noreferrer">grrwlf@gmail.com</a>:<br /><br /><blockquote class="tutanota_quote" style="border-left: 1px solid #93A3B8; padding-left: 10px; margin-left: 5px;">Hi. I'm trying (again) to write an Ur/Web module to provide API for<br />managing OS-level processes. I expect users to pass it a table<br />containing _at_least_ id, process command name, arguments, placeholder<br />for exit code and status string. It is expected that users will use<br />tables containing more problem-specific columns.<br /><br />The problem is that I cant use simple dml operations anymore. As a<br />start, I tried to write dummy insert using [demo/more/orm.ur] as<br />example, but was stopped by difficult [ensql] function. Could you<br />please help me to implement it? The code is quite short and listed<br />below.<br /><br />Regards,<br />Sergey<br /><br />---<br /><br />con jobinfo = [<br /> Id = int<br /> , ExitCode = option int<br /> , Cmd = string<br /> , Hint = string<br /> ]<br /><br />functor Make(M : sig<br /><br /> con u<br /><br /> constraint [Id,ExitCode,Cmd,Hint] ~ u<br /><br /> table t : (jobinfo ++ u)<br /><br /> sequence s<br /><br />end) = struct<br /><br /> open CallbackFFI<br /><br /> type row' = record (jobinfo ++ M.u)<br /><br /> (* fun ensql [avail ::_] (r : row') : $(map (sql_exp avail [] []) fs') = *)<br /> (* @map2 [meta] [fst] [fn ts :: (Type * Type) => sql_exp avail<br />[] [] ts.1] *)<br /> (* (fn [ts] meta v => @sql_inject meta.Inj v) *)<br /> (* M.folder M.cols r *)<br /><br /> (* createSync will start the job, but in this example it just does a<br />simple insert.<br /> args is a problem-specific part of the table record.<br /><br /> How to make this dml(insert..) work? *)<br /><br /> fun createSync (ji : record jobinfo, args : record M.u) :<br />transaction (option int) =<br /> i <- nextval M.s;<br /> dml(insert M.t ({Id = sql_inject ji.Id,<br /> ExitCode = sql_inject ji.ExitCode,<br /> Cmd = sql_inject ji.Cmd,<br /> Hint = sql_inject ji.Hint} ++ (ensql args) ));<br /><br /> return (Some i)<br /><br />end<br /><br />_______________________________________________<br />Ur mailing list<br /><a href="mailto:Ur@impredicative.com" target="_blank" rel="noopener noreferrer">Ur@impredicative.com</a><br /><a href="http://www.impredicative.com/cgi-bin/mailman/listinfo/ur" target="_blank" rel="noopener noreferrer">http://www.impredicative.com/cgi-bin/mailman/listinfo/ur</a></blockquote></div> </body>
</html>