<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">It's definitely not a crazy idea to
      connect to standard regexp functionality, say PCRE on the server
      and built-in JavaScript stuff on the client, via the FFI, with a
      richly typed interface.  Let me know if you have any specific
      questions on how to go about it.  Ziv's type signature examples
      should be helpful as a starting point.<br>
      <br>
      On 02/20/2017 12:00 AM, Artyom Shalkhakov wrote:<br>
    </div>
    <blockquote
cite="mid:CAKO6=qgcWv6KcW+kUj-8=MDN3yiEponrML=eEMUv9HWh7Afa9w@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">2017-02-20 10:47 GMT+06:00 <span
              dir="ltr"><<a moz-do-not-send="true"
                href="mailto:fold@tuta.io" target="_blank">fold@tuta.io</a>></span>:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div>
                Maybe just define another attribute in basis.urs?
                <div><br>
                </div>
                <div>It would be much interesting to define a DSEL
                  though. I have not seen any attempts to create a DSEL
                  for regular expressions.</div>
                <div><br>
                </div>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>Indeed! And it seems like it would be a nice exercise
              as well having some practical uses to it.</div>
            <div><br>
            </div>
            <div>I envision something along the lines of:</div>
            <div><br>
            </div>
            <div>datatype RegExp = ... (* constructors *)</div>
            <div><br>
            </div>
            <div>type t (* abstract, not exported outside the module *)</div>
            <div>val compile : RegExp -> t (* the trusted function *)</div>
            <div>val matches : string -> t -> bool (* check if
              passed-in string matches the expression *)</div>
            <div><br>
            </div>
            <div>And the implementation might use something unsafe (like
              a string, or an actual regexp object in JS). Then we could
              offload the interpretation of regexps to an off-the-shelf
              library. The [compile] function would print and escape the
              AST to a regexp string, and the Ur/Web compiler might
              actually optimize all of this away.</div>
            <div><br>
            </div>
            <div>If we are to take care of matching subgroups, that
              would require a more complicated type. I guess that should
              be doable as well, but I don't see immediately how to
              handle this.</div>
            <div> <br>
            </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div>
                <div><br>
                  <br>
                  20. Feb 2017 16:28 by <a moz-do-not-send="true"
                    href="mailto:artyom.shalkhakov@gmail.com"
                    rel="noopener noreferrer" target="_blank">artyom.shalkhakov@gmail.com</a>:
                  <div>
                    <div class="h5"><br>
                      <br>
                      <blockquote
                        class="m_-4979629669098642090tutanota_quote"
                        style="border-left:1px solid
                        #93a3b8;padding-left:10px;margin-left:5px">
                        <div>Hello all,
                          <div><br>
                          </div>
                          <div>'m doing form validation stuff, following
                            examples on MDN. [1]<br>
                          </div>
                          <div><br>
                          </div>
                          <div>It seems like Ur/Web doesn't handle
                            regular expressions?</div>
                          <div><br>
                          </div>
                          <div>I guess it should not be too diffcult to
                            define a DSEL in Ur/Web (just AST
                            constructors and a few trusted functions:
                            e.g. [compile : AST -> regexp], where
                            [regexp] is an abstract type, or maybe just
                            a string :-)) and have it work at least in
                            the browser.</div>
                          <div><br>
                          </div>
                          <div>Could somebody point me in the right
                            direction here?</div>
                          <div><br>
                          </div>
                          <div>-- <br>
                            <div
                              class="m_-4979629669098642090gmail_signature">Cheers,<br>
                              Artyom Shalkhakov<br>
                            </div>
                            <div
                              class="m_-4979629669098642090gmail_signature"><br>
                            </div>
                            <div
                              class="m_-4979629669098642090gmail_signature">[1] <a
                                moz-do-not-send="true"
href="https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation"
                                rel="noopener noreferrer"
                                target="_blank">https://developer.mozilla.<wbr>org/en-US/docs/Web/Guide/HTML/<wbr>HTML5/Constraint_validation</a></div>
                            <div
                              class="m_-4979629669098642090gmail_signature"><br>
                            </div>
                          </div>
                        </div>
                      </blockquote>
                    </div>
                  </div>
                </div>
              </div>
            </blockquote>
          </div>
          <br>
          <br clear="all">
          <div><br>
          </div>
          -- <br>
          <div class="gmail_signature" data-smartmail="gmail_signature">Cheers,<br>
            Artyom Shalkhakov<br>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Ur mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Ur@impredicative.com">Ur@impredicative.com</a>
<a class="moz-txt-link-freetext" href="http://www.impredicative.com/cgi-bin/mailman/listinfo/ur">http://www.impredicative.com/cgi-bin/mailman/listinfo/ur</a>
</pre>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>