<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">The key things missing in the original
      functor argument are a folder for [u] and a record of
      [sql_injectable] instances for it, both of which you'll see used
      in similar UPO functions mentioned earlier.<br>
      <br>
      BTW, the type of [insert] (in lib/ur/basis.urs) isn't magic and
      can be inspected just like any Ur type, and it should be possible
      to understand from first principles.<br>
      <br>
      On 02/11/2017 04:19 AM, <a class="moz-txt-link-abbreviated" href="mailto:fold@tuta.io">fold@tuta.io</a> wrote:<br>
    </div>
    <blockquote cite="mid:KcgT4wx--3-0@tuta.io" type="cite">
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      Actually, it might be quite simple.
      <div>Incomplete, but, hopefully, clear example:
        <div><br>
          <div>
            <div>table tab : $([Ix = int] ++ someColumns ++
              otherColumns) PRIMARY KEY Ix<br>
            </div>
            <div><br>
            </div>
            <div>fun test () : transaction xbody =</div>
            <div>    <...></div>
            <div>    tn <- now;</div>
            <div>    easy_insert tab ({Ix = ix} ++ field_defaults ++
              {Dated = tn});</div>
            <div>    <...></div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
              11. Feb 2017 22:09 by <a moz-do-not-send="true"
                href="mailto:fold@tuta.io" target="_blank" rel="noopener
                noreferrer">fold@tuta.io</a>:<br>
              <br>
              <blockquote class="tutanota_quote" style="border-left: 1px
                solid #93A3B8; padding-left: 10px; margin-left: 5px;">
                Sergey,
                <div><br>
                </div>
                <div>Something similar to this:</div>
                <div><a moz-do-not-send="true"
                    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 moz-do-not-send="true"
                    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 moz-do-not-send="true"
                    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 moz-do-not-send="true"
                    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</blockquote>
                </div>
              </blockquote>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>