Suave.io:一起使用pathScan和请求 [英] Suave.io: using pathScan and request together

查看:149
本文介绍了Suave.io:一起使用pathScan和请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚起床并运行Suave.io.我确信随着我对Applicatives的深入研究,这一点将变得更加清晰-但从较高的层次上,我看不到如何编写也适用request Applicative的pathScan规则.我发现的所有示例都只能做一个.在这两种情况下,它们都被应用到带有参数的函数中-因此,大概也可以以某种方式组合参数.

I'm just getting up and running with Suave.io. I'm sure this will become clearer as I dig more into Applicatives - but from a high level I can't see how to write a pathScan rule that applies the request applicative too. All examples I'm found only do one or the other. In both cases they are applied to a function taking arguments - so presumably the arguments would be combined somehow too.

推荐答案

pathScanrequest都具有生成Web部件的功能,因此无法使用>>=很好地链接它们.相反,您可以将一个嵌套在另一个内部(我认为这里的顺序并不重要):

Both pathScan and request take a function that produces a web part, so they cannot be nicely chained using >>=. Instead, you can nest one inside the other (I think the order does not really matter here):

pathScan "/some/%d" (fun num ->
  request (fun r -> 
    OK(sprintf "%d - %A" num r.url)))

这篇关于Suave.io:一起使用pathScan和请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆