[Ur] Function `queryL1` returns type `transaction (list $fs)` - How can I get the `list $fs` part and pass it to `List.mapX` - which expects type `list`?

Adam Chlipala adamc at csail.mit.edu
Sun Jul 19 18:52:26 EDT 2015


Sorry, you might not like my answer, but I feel like the right next step 
for you is to read (or reread) a tutorial about monadic programming in 
Haskell.  There's a pretty basic problem in your code below, and I feel 
like it should be easy to avoid with an understanding of what monadic 
code is, rather than just pattern-matching specific cases.

On 07/19/2015 06:49 PM, Stefan Scott Alexander wrote:
> An excerpt from my code is shown below. In this scenario, the user is 
> editing a "child" record, using a data-bound <select> widget to select 
> a primary key in the "parent" table, called `status`:
>
>   Widget = (fn [nm :: Name] =>
>     let
>       val statusOptionsList =
>         queryL1 (SELECT Id, Nam FROM status ORDER BY Nam)
>       val statusOptions =
>         List.mapX
>           (fn r => <xml><option>{r.Nam}</option></xml>)
> statusOptionsList  (* <<== LINE 44 IN ERR MSG BELOW! *)
>     in
>       <xml>
> <select{nm}>
> {statusOptions}
>         </select>
>       </xml>
>     end)
>
> I keep getting errors "unification failure" and "incompatible 
> constructors", eg:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20150719/ef14fcd0/attachment.html>


More information about the Ur mailing list