<div dir="ltr"><div>All of this reminds me of Conal Elliott's Tangible Values.</div><div><br></div><div><a href="http://conal.net/papers/Eros/">http://conal.net/papers/Eros/</a></div><div><br></div><div>(Not for web but the idea still applies.)</div><div><br></div><div>Ivan<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 2 Mar 2023 at 07:02, Olaf Klinke <<a href="mailto:olf@aatal-apotheke.de">olf@aatal-apotheke.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, 2023-03-02 at 15:51 +0200, Georgi Lyubenov wrote:<br>
> Hey Olaf,<br>
> <br>
> This is not an answer to your question, but I was reminded of Grace[0], <br>
> which is a language<br>
> with a "browser"[1] that allows you to type in terms and get back <br>
> webpages based on those terms<br>
> "automagically", which sounds like exactly what you need. I don't know <br>
> how it's implemented, so I don't know if<br>
> it is actually relevant to you, but it is worth noting that Grace itself <br>
> is implemented in Haskell.<br>
> <br>
> Cheers,<br>
> Georgi<br>
> <br>
> [0] <a href="https://github.com/Gabriella439/grace" rel="noreferrer" target="_blank">https://github.com/Gabriella439/grace</a><br>
> [1] <a href="https://trygrace.dev/" rel="noreferrer" target="_blank">https://trygrace.dev/</a><br>
> <br>
> On 3/2/23 12:54, Olaf Klinke wrote:<br>
> > Dear Cafe,<br>
> > <br>
> > has anyone ever attempted (and maybe succeeded) in building dynamic<br>
> > forms using one of the Haskell web frameworks (Yesod,Servant,...)?<br>
> > By "dynamic" form I mean a form that changes the number of fields based<br>
> > on selections the user makes in other fields of the form.<br>
> > <br>
> > For example, say one has an algebraic data type<br>
> > <br>
> > data T = Number Int | Check Bool T<br>
> > <br>
> > A form for such a type would initially consist of radio buttons or a<br>
> > drop-down list with options "Number" and "Check" that lets the user<br>
> > select the constructor. When "Number" is selected, an <input<br>
> > type="number"> field is shown. When "Check" is selected, an <input<br>
> > type="checkbox"> is displayed next to another form of this kind.<br>
> > <br>
> > In the end, one would use the GHC.Generics machinery to generate forms<br>
> > for a wide range of algebraic data types. I've seen this in the Clean<br>
> > language's iTask library [1] and it's very convenient.<br>
> > Of course this would involve a lot of JavaScript like<br>
> > document.createElement() as well as book-keeping how to re-asseble the<br>
> > fields into a T value upon submission. At least the latter is already<br>
> > handled by libraries such as yesod-form.<br>
> > <br>
> > Olaf<br>
> > <br>
> > [1] <a href="https://cloogle.org/src/#itasks/iTasks/UI/Editor/Generic" rel="noreferrer" target="_blank">https://cloogle.org/src/#itasks/iTasks/UI/Editor/Generic</a><br>
> > [2] <a href="https://github.com/haskell-servant/servant-swagger/issues/80" rel="noreferrer" target="_blank">https://github.com/haskell-servant/servant-swagger/issues/80</a><br>
> > <br>
> > <br>
<br>
Thanks for the pointer! <br>
<br>
The Grace README says under Notable Omissions:<br>
<br>
>Recursion or recursive data types<br>
><br>
>Grace only supports two built-in recursive types, which are List and<br>
>JSON, but does not support user-defined recursion or anonymous<br>
>recursion.<br>
><br>
>User-defined datatypes<br>
><br>
>All data types in Grace are anonymous (e.g. anonymous records and<br>
>anonymous unions), and there is no concept of a data declaration<br>
<br>
The tutorial shows how Grace function inputs are mapped to forms, where<br>
functions with List input indeed have a form that is "dynamic" in the<br>
sense I defined. Otherwise there is only one input field per function<br>
argument. That means complex types are to be input in JSON syntax and<br>
parsed. <br>
Instead of a DSL, I'd prefer a shallow embedding into Haskell, so that<br>
one can leverage all the available machinery. <br>
Yet Grace already goes a long way towards what I am after. <br>
<br>
Olaf<br>
<br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>