2017-02-20 10:47 GMT+06:00 <[email protected]>: > Maybe just define another attribute in basis.urs? > > It would be much interesting to define a DSEL though. I have not seen any > attempts to create a DSEL for regular expressions. > > Indeed! And it seems like it would be a nice exercise as well having some practical uses to it.
I envision something along the lines of: datatype RegExp = ... (* constructors *) type t (* abstract, not exported outside the module *) val compile : RegExp -> t (* the trusted function *) val matches : string -> t -> bool (* check if passed-in string matches the expression *) 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. 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. > > > 20. Feb 2017 16:28 by [email protected]: > > > Hello all, > > 'm doing form validation stuff, following examples on MDN. [1] > > It seems like Ur/Web doesn't handle regular expressions? > > 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. > > Could somebody point me in the right direction here? > > -- > Cheers, > Artyom Shalkhakov > > [1] https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/ > HTML5/Constraint_validation > > -- Cheers, Artyom Shalkhakov
_______________________________________________ Ur mailing list [email protected] http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
