[Ur] JSON web service/api?
Isaac Torbett
izacht13 at gmail.com
Wed Mar 8 18:22:59 EST 2017
I should have looked at the mail archive, this question has already been
asked.
On Wed, Mar 8, 2017 at 2:24 PM, Isaac Torbett <izacht13 at gmail.com> wrote:
> Huh, I still don't understand when to use return, and when not too, 'll
> have to find a tutorial for that then. Ill look at section 10, thanks.
>
> I don't really understand what you mean by arguments, arguments in the
> transaction descriptor? If so what would that look like?
>
> Again thanks for the help.
>
> On Wed, Mar 8, 2017 at 2:19 PM, Adam Chlipala <adamc at csail.mit.edu> wrote:
>
>> On 03/08/2017 01:51 PM, Isaac Torbett wrote:
>>
>>> I'm trying to get the urweb server to return json, but what is the
>>> type/kind I should put in the transaction monad?
>>>
>>>
>>> val main : <here> -> transaction page
>>>
>>>
>>> What would I put in <here>?
>>>
>>> Furthermore- I don't even know if my json-like structure is allowed, the
>>> compiler isn't complaining about it, so maybe it's fine.
>>>
>>
>> I think Section 10 of the manual explains everything about how to write
>> handlers that provide non-HTML-based APIs. In short, you probably want to
>> use argument type [postBody] or [queryString], depending on how the JSON
>> comes in. You can also use [returnBlob] to return JSON instead of HTML.
>>
>> fun main () = return queryX1 (SELECT topic.Title, topic.Body FROM topic)
>>>
>>
>> It looks like you're hung up on the basics of programming with monads,
>> for which I'd recommend a Haskell monad tutorial. But the case-specific
>> fix is to remove the [return].
>>
>> _______________________________________________
>> Ur mailing list
>> Ur at impredicative.com
>> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20170308/156b4c53/attachment.html>
More information about the Ur
mailing list