Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Another possibly interesting alternative is to use F# quotations.</p> <p>Quotations allow you to treat part of the program as data, so you can get the AST, analyze it and translate it to other language or execute it in some non-standard way. Together with the flexibility of F#, you should be able to express many things, so you'd have to develop an internal F# DSL/combinator library for describing the rules and a translator/interpreter for F# quotations to run them.</p> <p>Not sure how a bussines rule might look like, but you could write something like this:</p> <pre><code>let rule = &lt;@ if (exists customer having validEmail) then success else require whatever @&gt; </code></pre> <p>I wrote an introduction to this topic on my blog. Unfortunatelly, there have been some big changes in the F# CTP and I haven't yet updated the source code, but it should give you a good idea of what are the possibilities &amp; limitations of this approach.</p> <ul> <li><a href="http://tomasp.net/blog/fsharp-quotation-samples.aspx" rel="noreferrer">F# Quotations Samples on CodePlex</a> - TomasP.Net</li> </ul> <p>A good example of DSL is F# unit testing framewrok:</p> <ul> <li><a href="http://weblogs.asp.net/podwysocki/archive/2008/06/19/announcing-fstest-a-testing-dsl-for-f.aspx" rel="noreferrer">Announcing FsTest - A Testing DSL for F#</a> - Matthew Podwysocki</li> </ul> <p><em>[EDIT]</em> Just to clarify why I think this may be a good approach:</p> <ul> <li>If you use Visual Studio for editting the DSLs (and you can use the Shell version with F# installed for free), you'll get a very good editing experience for free. Not only syntax highlighting, but also IntelliSense that'll suggest the possible constructs and also a background type-checking that serves as 'grammar' checker for your DSL.</li> <li>Compared to other approaches this one is perhaps one of the easiest to implement.</li> <li>The only limitation is that you're bounded by the F# syntax. However, designing your own language is really difficult, so this may not be that bad at all. Especially given the flexibility of F#.</li> </ul> <p><em>[/EDIT]</em></p> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload